In this notebook, we'll look into modelling implied trading within an exchange. Implied trading refers to ability to connect liquidity on strategy and outright order books (e.g. Euronext).

1 Type definitions and printers

1.1 Model type definitions

Our first goal is to setup the various type definitions that we'll use later on.

In [1]:
type side = BUY | SELL

type outright_id = OUT1 | OUT2 | OUT3
type strategy_id = STRAT1 | STRAT2
type month = Mar | Jun | Sep | Dec

(* Map an outright with an expiry *)
let contract_expiry = function
  | OUT1 -> Mar
  | OUT2 -> Jun
  | OUT3 -> Sep

(* Convert month to an integer *)
let month_to_int = function
  | Mar -> 3
  | Jun -> 6
  | Sep -> 9
  | Dec -> 12
;;

(* Return true of m1 is nearer (or equal) to m2 *)
let month_comp (m1 : month) (m2 : month) =
  (month_to_int m1) < (month_to_int  m2)
;;

type instrument =
  | Strategy of strategy_id
  | Outright of outright_id

(* Level information *)
type level_info = {
  li_qty : int
  ; li_price : int
}

(* best bid and ask information *)
type best_bid_ask = {
  bid_info : level_info option
  ; ask_info : level_info option
}

(* Best bid/ask for all of the books *)
type books_info = {
  book1 : best_bid_ask
  ; book2 : best_bid_ask
  ; book3 : best_bid_ask
}

(* Order type *)
type order = {
  o_qty : int
  ; o_price : int
  ; o_time : int
  ; o_id : int
  ; o_side : side
  ; o_client_id : int
  ; o_inst : instrument
  ; o_is_implied : bool
}

(* Helper function to make order creation simpler *)
let make si qty price id inst clientid isimp time =
  {o_qty = qty ; o_price = price; o_id = id; o_side = si;
   o_client_id = clientid; o_inst = inst; o_is_implied = isimp;
   o_time = time }


(* outright order book *)
type book = {
  b_buys : order list
  ; b_sells : order list
}

let empty_book = { b_buys = []; b_sells = [] }

(* Individual leg *)
type leg = {
  leg_sec_idx : outright_id
  ; leg_mult : int
}

(* Strategy is composed of legs *)
type strategy = {
  time_created : int
  ; leg1 : leg
  ; leg2 : leg
  ; leg3 : leg
}

(* Helper function to make strategy creation smaller *)
let make_strat tcreated m1 m2 m3 = {
  time_created = tcreated
  ; leg1 = { leg_sec_idx = OUT1; leg_mult = m1 }
  ; leg2 = { leg_sec_idx = OUT2; leg_mult = m2 }
  ; leg3 = { leg_sec_idx = OUT3; leg_mult = m3 }
}

type implied_strat_ord = {
  max_strat : int option
  ; strat_price : int option
}

(* New order message *)
type new_ord_msg = {
  no_client_id : int
  ; no_inst_type : instrument
  ; no_qty : int
  ; no_side : side
  ; no_price : int
}

(* cancel order ID *)
type cancel_ord_msg = {
  co_client_id : int
  ; co_order_id : int
  ; co_instrument : instrument
  ; co_side : side
}

(* Inbound messages type *)
type inbound_msg =
  | NewOrder of new_ord_msg
  | CancelOrder of cancel_ord_msg
  | ImpliedUncross

(* Helper function for creating new order messages *)
let make_no_msg cid inst qty sd p =
 NewOrder {
  no_client_id = cid
  ; no_inst_type = inst
  ; no_qty = qty
  ; no_side = sd
  ; no_price = p
 }

(* ack message *)
type ack_msg = {
  ack_client_id : int
  ; ack_order_id : int
  ; ack_inst_type : instrument
  ; ack_qty : int
  ; ack_side : side
  ; ack_price : int
}

(* fill information *)
type fill = {
  fill_client_id : int
  ; fill_qty : int
  ; fill_price : int
  ; fill_order_id : int
  ; fill_order_done : bool
}

(* uncross result *)
type uncross_res = {
  uncrossed_book : book
  ; uncrossed_fills : fill list
  ; uncrossed_qty : int
}

(* outbound message type *)
type outbound_msg =
  | Ack of ack_msg
  | Fill of fill
  | UncrossResult of uncross_res
;;

(* The entire market - strategy definitions, order books, messages, etc. s*)
type market = {

  (* current time*)
  curr_time : int

  (* used for order ID counter *)
  ; last_ord_id : int

  (* two strategy definitions *)
  ; strat1    : strategy
  ; strat2    : strategy

  (* outright books *)
  ; out_book1 : book
  ; out_book2 : book
  ; out_book3 : book

  (* strategy books *)
  ; s_book1   : book
  ; s_book2   : book

  (* inbound and outbound message queues *)
  ; inbound_msgs  : inbound_msg list
  ; outbound_msgs : outbound_msg list

}
Out[1]:
type side = BUY | SELL
type outright_id = OUT1 | OUT2 | OUT3
type strategy_id = STRAT1 | STRAT2
type month = Mar | Jun | Sep | Dec
val contract_expiry : outright_id -> month = <fun>
val month_to_int : month -> int = <fun>
val month_comp : month -> month -> bool = <fun>
type instrument = Strategy of strategy_id | Outright of outright_id
type level_info = { li_qty : int; li_price : int; }
type best_bid_ask = {
  bid_info : level_info option;
  ask_info : level_info option;
}
type books_info = {
  book1 : best_bid_ask;
  book2 : best_bid_ask;
  book3 : best_bid_ask;
}
type order = {
  o_qty : int;
  o_price : int;
  o_time : int;
  o_id : int;
  o_side : side;
  o_client_id : int;
  o_inst : instrument;
  o_is_implied : bool;
}
val make :
  side -> int -> int -> int -> instrument -> int -> bool -> int -> order =
  <fun>
type book = { b_buys : order list; b_sells : order list; }
val empty_book : book = {b_buys = []; b_sells = []}
type leg = { leg_sec_idx : outright_id; leg_mult : int; }
type strategy = { time_created : int; leg1 : leg; leg2 : leg; leg3 : leg; }
val make_strat : int -> int -> int -> int -> strategy = <fun>
type implied_strat_ord = {
  max_strat : int option;
  strat_price : int option;
}
type new_ord_msg = {
  no_client_id : int;
  no_inst_type : instrument;
  no_qty : int;
  no_side : side;
  no_price : int;
}
type cancel_ord_msg = {
  co_client_id : int;
  co_order_id : int;
  co_instrument : instrument;
  co_side : side;
}
type inbound_msg =
    NewOrder of new_ord_msg
  | CancelOrder of cancel_ord_msg
  | ImpliedUncross
val make_no_msg : int -> instrument -> int -> side -> int -> inbound_msg =
  <fun>
type ack_msg = {
  ack_client_id : int;
  ack_order_id : int;
  ack_inst_type : instrument;
  ack_qty : int;
  ack_side : side;
  ack_price : int;
}
type fill = {
  fill_client_id : int;
  fill_qty : int;
  fill_price : int;
  fill_order_id : int;
  fill_order_done : bool;
}
type uncross_res = {
  uncrossed_book : book;
  uncrossed_fills : fill list;
  uncrossed_qty : int;
}
type outbound_msg =
    Ack of ack_msg
  | Fill of fill
  | UncrossResult of uncross_res
type market = {
  curr_time : int;
  last_ord_id : int;
  strat1 : strategy;
  strat2 : strategy;
  out_book1 : book;
  out_book2 : book;
  out_book3 : book;
  s_book1 : book;
  s_book2 : book;
  inbound_msgs : inbound_msg list;
  outbound_msgs : outbound_msg list;
}

1.2 Custom type printers

One of Imandra's powerful features is the ability to combine logic (pure subset of OCaml) and program (all of OCaml) modes. In the following cell, we will create and install a custom type printer (HTML) for an order book. So that next time a value of this type is computed within a cell, this printer would be used instead of the generic one.

In [2]:
(* Here's an example of a custom printer that we can install for arbitrary data types. *)

#program;;
#require "tyxml";;
let html_of_order (o : order) =
  let module H = Tyxml.Html in
  H.div
  ~a:(if o.o_is_implied then [H.a_style "color: red"] else [])
  [ H.div
    ~a:[H.a_style "font-size: 1.4em"]
    [H.txt (Format.asprintf "%s (%s)" (Z.to_string o.o_price) (Z.to_string o.o_qty))]
  ; H.div (if o.o_is_implied then [H.txt "Implied"] else [])
  ]

let doc_of_order (o:order) =
  let module H = Tyxml.Html in
  Document.html (H.div [html_of_order o]);;

#install_doc doc_of_order

let html_of_book ?(title="") (b: book) =
  let module H = Tyxml.Html in
  let rec build_rows acc buys sells =
      match buys, sells with
      | b :: bs, s :: ss -> build_rows (acc @ [H.tr [H.td [html_of_order b]; H.td [html_of_order s]]]) bs ss
      | b :: bs, [] -> build_rows (acc @ [H.tr [H.td [html_of_order b]; H.td [H.txt "-"]]]) bs []
      | [], s :: ss -> build_rows (acc @ [H.tr [H.td [H.txt "-"]; H.td [html_of_order s]]]) [] ss
      | [], [] -> acc
  in
  H.div
  ~a:[H.a_style "margin-right:1em; display: flex; flex-direction: column; align-items: center; justify-content: flex-start"]
  [ H.div ~a:[H.a_style "font-weight: bold"] [H.txt title]
  ; H.table
    ~thead:(H.thead [H.tr [H.th [H.txt "Buys"]; H.th [H.txt "Sells"]]])
    (build_rows [] b.b_buys b.b_sells)]

let doc_of_book (b:book) =
  let module H = Tyxml.Html in
  Document.html (H.div [html_of_book ~title:"M1 Mar21" b]);;

#install_doc doc_of_book;;

let html_of_market (m: market) =
  let module H = Tyxml.Html in
  H.div
  [ H.div ~a:[H.a_style "display: flex"]
    [ html_of_book ~title:"Strategy 1" m.s_book1
    ; html_of_book ~title:"Strategy 2" m.s_book2
    ]
  ; H.div ~a:[H.a_style "margin-top: 1em; display: flex"]
    [ html_of_book ~title:"Book 1" m.out_book1
    ; html_of_book ~title:"Book 2" m.out_book2
    ; html_of_book ~title:"Book 3" m.out_book3
    ]]

let doc_of_market (m : market) =
  let module H = Tyxml.Html in
  Document.html (html_of_market m);;

#install_doc doc_of_market;;

#logic;;
Out[2]:
/usr/local/var/imandra/_opam/lib/re: added to search path
/usr/local/var/imandra/_opam/lib/re/re.cma: loaded
/usr/local/var/imandra/_opam/lib/uchar: added to search path
/usr/local/var/imandra/_opam/lib/uutf: added to search path
/usr/local/var/imandra/_opam/lib/uutf/uutf.cma: loaded
/usr/local/var/imandra/_opam/lib/tyxml/functor: added to search path
/usr/local/var/imandra/_opam/lib/tyxml/functor/tyxml_f.cma: loaded
/usr/local/var/imandra/_opam/lib/tyxml: added to search path
/usr/local/var/imandra/_opam/lib/tyxml/tyxml.cma: loaded
- : unit = ()
val html_of_order : order -> [> Html_types.div ] Tyxml_html.elt = <fun>
File "jupyter cell 2", line 17, characters 16-41:
Error: This expression has type [> Html_types.div ] H.elt
       but an expression was expected of type Document.html
Line 2, characters 18-30:
2 |           let d = doc_of_order x in
                      ^^^^^^^^^^^^
Error: Unbound value doc_of_order
val html_of_book :
  ?title:string -> book -> [> Html_types.div ] Tyxml_html.elt = <fun>
File "jupyter cell 2", line 39, characters 16-58:
Error: This expression has type [> Html_types.div ] H.elt
       but an expression was expected of type Document.html
Line 2, characters 18-29:
2 |           let d = doc_of_book x in
                      ^^^^^^^^^^^
Error: Unbound value doc_of_book
val html_of_market : market -> [> Html_types.div ] Tyxml_html.elt = <fun>
File "jupyter cell 2", line 58, characters 16-34:
Error: This expression has type [> Html_types.div ] H.elt
       but an expression was expected of type Document.html
Line 2, characters 18-31:
2 |           let d = doc_of_market x in
                      ^^^^^^^^^^^^^
Error: Unbound value doc_of_market

1.3 Custom type printer example

In [3]:
let leg = { leg_sec_idx = OUT1; leg_mult = 1 } in

let strat = { time_created = 0; leg1 = leg; leg2 = leg; leg3 = leg } in

let b1 = {
  b_buys = [
    (make BUY 100 54 1 (Outright OUT1) 1 true 1)
    ;(make BUY 100 54 2 (Outright OUT1) 1 false 1)
  ]
  ; b_sells = [
    (make SELL 100 54 3 (Outright OUT1) 1 false 1)
    ;(make SELL 100 54 4 (Outright OUT1) 1 false 1)
  ] } in

  { curr_time = 1
  ; last_ord_id = 1
  ; strat1 = strat
  ; strat2 = strat
  ; out_book1 = b1
  ; out_book2 = b1
  ; out_book3 = b1
  ; s_book1 = b1
  ; s_book2 = b1
  ; inbound_msgs = []
  ; outbound_msgs = []
  }
Out[3]:
- : market =
{curr_time = 1; last_ord_id = 1;
 strat1 =
  {time_created = 0; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
   leg2 = {leg_sec_idx = OUT1; leg_mult = 1};
   leg3 = {leg_sec_idx = OUT1; leg_mult = 1}};
 strat2 =
  {time_created = 0; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
   leg2 = {leg_sec_idx = OUT1; leg_mult = 1};
   leg3 = {leg_sec_idx = OUT1; leg_mult = 1}};
 out_book1 =
  {b_buys =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 1; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = true};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 2; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
   b_sells =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 3; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
 out_book2 =
  {b_buys =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 1; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = true};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 2; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
   b_sells =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 3; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
 out_book3 =
  {b_buys =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 1; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = true};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 2; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
   b_sells =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 3; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
 s_book1 =
  {b_buys =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 1; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = true};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 2; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
   b_sells =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 3; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
 s_book2 =
  {b_buys =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 1; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = true};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 2; o_side = BUY;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
   b_sells =
    [{o_qty = 100; o_price = 54; o_time = 1; o_id = 3; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false};
     {o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = SELL;
      o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
 inbound_msgs = []; outbound_msgs = []}

2. Outright uncrossing logic

2.1 Order book operatons (inserting, cancelling orders)

In [4]:
(* Convert fills into outbound messages *)
let rec create_fill_msgs (f : fill list) =
  match f with
  | [] -> []
  | x::xs -> (Fill x) :: create_fill_msgs xs

(* TODO: recode this with higher-order functions *)
let rec cancel_ord_side (orders : order list) (c : cancel_ord_msg) =
  match orders with
  | [] -> []
  | x::xs ->
    begin
      if (x.o_client_id = c.co_client_id) && (x.o_id = c.co_order_id) then xs
      else x :: (cancel_ord_side xs c)
    end

(* Helper to cancel orders *)
let cancel_ord_book (co : cancel_ord_msg) (b : book) =
  match co.co_side with
  | BUY -> { b with b_buys = (cancel_ord_side b.b_buys co) }
  | SELL -> { b with b_sells = (cancel_ord_side b.b_sells co) }

(* function used insert individual orders *)
let rec insert_order_side (orders : order list) (o : order) =
  match orders with
  | [] -> [ o ]
  | x::xs ->
    begin
      if o.o_side = BUY then
        (if o.o_price > x.o_price then o :: orders else x :: (insert_order_side xs o))
      else
        (if o.o_price < x.o_price then o :: orders else x :: (insert_order_side xs o))
    end

(* insert order into the book *)
let insert_order (o : order) (b : book) =
  if o.o_side = BUY then
    { b with b_buys = (insert_order_side b.b_buys o) }
  else
    { b with b_sells = (insert_order_side b.b_sells o) }

(* The fills are adjusted to a single fill price during the uncross *)
let rec adjust_fill_prices (fills : fill list) ( f_price : int ) =
  match fills with
  | [] -> []
  | x::xs -> { x with fill_price = f_price } :: ( adjust_fill_prices xs f_price )
;;
Out[4]:
val create_fill_msgs : fill list -> outbound_msg list = <fun>
val cancel_ord_side : order list -> cancel_ord_msg -> order list = <fun>
val cancel_ord_book : cancel_ord_msg -> book -> book = <fun>
val insert_order_side : order list -> order -> order list = <fun>
val insert_order : order -> book -> book = <fun>
val adjust_fill_prices : fill list -> int -> fill list = <fun>
termination proof

Termination proof

call `create_fill_msgs (List.tl f)` from `create_fill_msgs f`
originalcreate_fill_msgs f
subcreate_fill_msgs (List.tl f)
original ordinalOrdinal.Int (_cnt f)
sub ordinalOrdinal.Int (_cnt (List.tl f))
path[not Is_a([], f)]
proof
detailed proof
ground_instances3
definitions0
inductions0
search_time
0.019s
details
Expand
smt_stats
num checks8
arith-assume-eqs12
arith-make-feasible77
arith-max-columns51
arith-conflicts2
rlimit count3996
mk clause114
datatype occurs check45
mk bool var176
arith-lower44
datatype splits3
decisions65
propagations73
interface eqs12
arith-max-rows25
conflicts8
datatype accessor ax9
datatype constructor ax7
num allocs2395653
final checks18
added eqs131
del clause87
arith eq adapter42
arith-upper68
memory10.010000
max memory10.010000
Expand
  • start[0.019s]
      let (_x_0 : int) = count.list count.fill f in
      let (_x_1 : fill list) = List.tl f in
      let (_x_2 : int) = count.list count.fill _x_1 in
      not Is_a([], f) && _x_0 >= 0 && _x_2 >= 0
      ==> Is_a([], _x_1) || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
  • simplify
    into
    let (_x_0 : fill list) = List.tl f in
    let (_x_1 : int) = count.list count.fill _x_0 in
    let (_x_2 : int) = count.list count.fill f in
    (Is_a([], _x_0) || Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2))
    || not ((not Is_a([], f) && _x_2 >= 0) && _x_1 >= 0)
    expansions
    []
    rewrite_steps
      forward_chaining
      • unroll
        expr
        (|`count.list count.fill[0]`_1869| f_1858)
        expansions
        • unroll
          expr
          (|`count.list count.fill[0]`_1869| (|get.::.1_1842| f_1858))
          expansions
          • unroll
            expr
            (|Ordinal.<<_119| (|Ordinal.Int_108|
                                (|`count.list count.fill[0]`_1869| (|get.::…
            expansions
            • Unsat

            termination proof

            Termination proof

            call `cancel_ord_side (List.tl orders) c` from `cancel_ord_side orders c`
            originalcancel_ord_side orders c
            subcancel_ord_side (List.tl orders) c
            original ordinalOrdinal.Int (_cnt orders)
            sub ordinalOrdinal.Int (_cnt (List.tl orders))
            path[let (_x_0 : order) = List.hd orders in not (_x_0.o_client_id = c.co_client_id && _x_0.o_id = c.co_order_id) && not Is_a([], orders)]
            proof
            detailed proof
            ground_instances3
            definitions0
            inductions0
            search_time
            0.020s
            details
            Expand
            smt_stats
            num checks8
            arith-assume-eqs15
            arith-make-feasible81
            arith-max-columns59
            arith-conflicts2
            rlimit count5459
            mk clause130
            datatype occurs check71
            mk bool var340
            arith-lower45
            datatype splits51
            decisions102
            propagations75
            interface eqs15
            arith-max-rows29
            conflicts6
            datatype accessor ax34
            datatype constructor ax80
            num allocs5963880
            final checks21
            added eqs400
            del clause97
            arith eq adapter43
            arith-upper70
            memory10.420000
            max memory10.420000
            Expand
            • start[0.020s]
                let (_x_0 : order) = List.hd orders in
                let (_x_1 : int) = c.co_client_id in
                let (_x_2 : int) = c.co_order_id in
                let (_x_3 : int) = count.list count.order orders in
                let (_x_4 : order list) = List.tl orders in
                let (_x_5 : int) = count.list count.order _x_4 in
                let (_x_6 : order) = List.hd _x_4 in
                not (_x_0.o_client_id = _x_1 && _x_0.o_id = _x_2)
                && not Is_a([], orders) && _x_3 >= 0 && _x_5 >= 0
                ==> not
                    (not (_x_6.o_client_id = _x_1 && _x_6.o_id = _x_2)
                     && not Is_a([], _x_4))
                    || Ordinal.( << ) (Ordinal.Int _x_5) (Ordinal.Int _x_3)
            • simplify
              into
              let (_x_0 : order list) = List.tl orders in
              let (_x_1 : order) = List.hd _x_0 in
              let (_x_2 : int) = c.co_client_id in
              let (_x_3 : int) = c.co_order_id in
              let (_x_4 : int) = count.list count.order _x_0 in
              let (_x_5 : int) = count.list count.order orders in
              let (_x_6 : order) = List.hd orders in
              (not
               (not (_x_1.o_client_id = _x_2 && _x_1.o_id = _x_3) && not Is_a([], _x_0))
               || Ordinal.( << ) (Ordinal.Int _x_4) (Ordinal.Int _x_5))
              || not
                 (((not (_x_6.o_client_id = _x_2 && _x_6.o_id = _x_3)
                    && not Is_a([], orders))
                   && _x_5 >= 0)
                  && _x_4 >= 0)
              expansions
              []
              rewrite_steps
                forward_chaining
                • unroll
                  expr
                  (|`count.list count.order[0]`_1917| orders_1904)
                  expansions
                  • unroll
                    expr
                    (|`count.list count.order[0]`_1917| (|get.::.1_1902| orders_1904))
                    expansions
                    • unroll
                      expr
                      (|Ordinal.<<_119| (|Ordinal.Int_108|
                                          (|`count.list count.order[0]`_1917|
                             …
                      expansions
                      • Unsat

                      termination proof

                      Termination proof

                      call `insert_order_side (List.tl orders) o` from `insert_order_side orders o`
                      originalinsert_order_side orders o
                      subinsert_order_side (List.tl orders) o
                      original ordinalOrdinal.Int (_cnt orders)
                      sub ordinalOrdinal.Int (_cnt (List.tl orders))
                      path[not (o.o_price > (List.hd orders).o_price) && o.o_side = BUY && not Is_a([], orders)]
                      proof
                      detailed proof
                      ground_instances3
                      definitions0
                      inductions0
                      search_time
                      0.025s
                      details
                      Expand
                      smt_stats
                      num checks8
                      arith-assume-eqs13
                      arith-make-feasible91
                      arith-max-columns61
                      arith-conflicts2
                      rlimit count11286
                      mk clause131
                      datatype occurs check63
                      mk bool var365
                      arith-lower52
                      datatype splits59
                      decisions103
                      propagations91
                      interface eqs13
                      arith-max-rows30
                      conflicts6
                      datatype accessor ax36
                      datatype constructor ax80
                      num allocs12459982
                      final checks19
                      added eqs445
                      del clause98
                      arith eq adapter48
                      arith-upper82
                      memory16.530000
                      max memory16.530000
                      Expand
                      • start[0.025s]
                          let (_x_0 : int) = o.o_price in
                          let (_x_1 : bool) = o.o_side = BUY in
                          let (_x_2 : int) = count.list count.order orders in
                          let (_x_3 : order list) = List.tl orders in
                          let (_x_4 : int) = count.list count.order _x_3 in
                          let (_x_5 : int) = (List.hd _x_3).o_price in
                          let (_x_6 : bool) = not Is_a([], _x_3) in
                          not (_x_0 > (List.hd orders).o_price)
                          && _x_1 && not Is_a([], orders) && _x_2 >= 0 && _x_4 >= 0
                          ==> not (not (_x_0 > _x_5) && _x_1 && _x_6)
                              && not (not (_x_0 < _x_5) && not _x_1 && _x_6)
                              || Ordinal.( << ) (Ordinal.Int _x_4) (Ordinal.Int _x_2)
                      • simplify
                        into
                        let (_x_0 : order list) = List.tl orders in
                        let (_x_1 : int) = count.list count.order _x_0 in
                        let (_x_2 : int) = count.list count.order orders in
                        let (_x_3 : int) = o.o_price in
                        let (_x_4 : int) = (List.hd _x_0).o_price in
                        let (_x_5 : bool) = o.o_side = BUY in
                        let (_x_6 : bool) = not Is_a([], _x_0) in
                        (Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2)
                         || not ((_x_3 <= _x_4 && _x_5) && _x_6)
                            && not ((_x_4 <= _x_3 && not _x_5) && _x_6))
                        || not
                           ((((_x_3 <= (List.hd orders).o_price && _x_5) && not Is_a([], orders))
                             && _x_2 >= 0)
                            && _x_1 >= 0)
                        expansions
                        []
                        rewrite_steps
                          forward_chaining
                          • unroll
                            expr
                            (|`count.list count.order[0]`_2001| orders_1986)
                            expansions
                            • unroll
                              expr
                              (|`count.list count.order[0]`_2001| (|get.::.1_1985| orders_1986))
                              expansions
                              • unroll
                                expr
                                (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                    (|`count.list count.order[0]`_2001|
                                       …
                                expansions
                                • Unsat

                                call `insert_order_side (List.tl orders) o` from `insert_order_side orders o`
                                originalinsert_order_side orders o
                                subinsert_order_side (List.tl orders) o
                                original ordinalOrdinal.Int (_cnt orders)
                                sub ordinalOrdinal.Int (_cnt (List.tl orders))
                                path[not (o.o_price < (List.hd orders).o_price) && not (o.o_side = BUY) && not Is_a([], orders)]
                                proof
                                detailed proof
                                ground_instances3
                                definitions0
                                inductions0
                                search_time
                                0.032s
                                details
                                Expand
                                smt_stats
                                num checks8
                                arith-assume-eqs15
                                arith-make-feasible73
                                arith-max-columns62
                                arith-conflicts2
                                rlimit count5525
                                mk clause129
                                datatype occurs check71
                                mk bool var354
                                arith-lower42
                                datatype splits59
                                decisions91
                                propagations81
                                interface eqs15
                                arith-max-rows31
                                conflicts7
                                datatype accessor ax37
                                datatype constructor ax83
                                num allocs9025966
                                final checks21
                                added eqs426
                                del clause96
                                arith eq adapter40
                                arith-upper66
                                memory13.680000
                                max memory13.680000
                                Expand
                                • start[0.032s]
                                    let (_x_0 : int) = o.o_price in
                                    let (_x_1 : bool) = o.o_side = BUY in
                                    let (_x_2 : bool) = not _x_1 in
                                    let (_x_3 : int) = count.list count.order orders in
                                    let (_x_4 : order list) = List.tl orders in
                                    let (_x_5 : int) = count.list count.order _x_4 in
                                    let (_x_6 : int) = (List.hd _x_4).o_price in
                                    let (_x_7 : bool) = not Is_a([], _x_4) in
                                    not (_x_0 < (List.hd orders).o_price)
                                    && _x_2 && not Is_a([], orders) && _x_3 >= 0 && _x_5 >= 0
                                    ==> not (not (_x_0 > _x_6) && _x_1 && _x_7)
                                        && not (not (_x_0 < _x_6) && _x_2 && _x_7)
                                        || Ordinal.( << ) (Ordinal.Int _x_5) (Ordinal.Int _x_3)
                                • simplify
                                  into
                                  let (_x_0 : order list) = List.tl orders in
                                  let (_x_1 : int) = count.list count.order _x_0 in
                                  let (_x_2 : int) = count.list count.order orders in
                                  let (_x_3 : int) = o.o_price in
                                  let (_x_4 : int) = (List.hd _x_0).o_price in
                                  let (_x_5 : bool) = o.o_side = BUY in
                                  let (_x_6 : bool) = not Is_a([], _x_0) in
                                  let (_x_7 : bool) = not _x_5 in
                                  (Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2)
                                   || not ((_x_3 <= _x_4 && _x_5) && _x_6)
                                      && not ((_x_4 <= _x_3 && _x_7) && _x_6))
                                  || not
                                     (((((List.hd orders).o_price <= _x_3 && _x_7) && not Is_a([], orders))
                                       && _x_2 >= 0)
                                      && _x_1 >= 0)
                                  expansions
                                  []
                                  rewrite_steps
                                    forward_chaining
                                    • unroll
                                      expr
                                      (|`count.list count.order[0]`_2001| orders_1986)
                                      expansions
                                      • unroll
                                        expr
                                        (|`count.list count.order[0]`_2001| (|get.::.1_1985| orders_1986))
                                        expansions
                                        • unroll
                                          expr
                                          (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                              (|`count.list count.order[0]`_2001|
                                                 …
                                          expansions
                                          • Unsat

                                          termination proof

                                          Termination proof

                                          call `adjust_fill_prices (List.tl fills) f_price` from `adjust_fill_prices fills f_price`
                                          originaladjust_fill_prices fills f_price
                                          subadjust_fill_prices (List.tl fills) f_price
                                          original ordinalOrdinal.Int (_cnt fills)
                                          sub ordinalOrdinal.Int (_cnt (List.tl fills))
                                          path[not Is_a([], fills)]
                                          proof
                                          detailed proof
                                          ground_instances3
                                          definitions0
                                          inductions0
                                          search_time
                                          0.051s
                                          details
                                          Expand
                                          smt_stats
                                          num checks8
                                          arith-assume-eqs12
                                          arith-make-feasible77
                                          arith-max-columns51
                                          arith-conflicts2
                                          rlimit count3996
                                          mk clause114
                                          datatype occurs check45
                                          mk bool var176
                                          arith-lower44
                                          datatype splits3
                                          decisions65
                                          propagations73
                                          interface eqs12
                                          arith-max-rows25
                                          conflicts8
                                          datatype accessor ax9
                                          datatype constructor ax7
                                          num allocs20414741
                                          final checks18
                                          added eqs131
                                          del clause87
                                          arith eq adapter42
                                          arith-upper68
                                          memory16.870000
                                          max memory16.870000
                                          Expand
                                          • start[0.051s]
                                              let (_x_0 : int) = count.list count.fill fills in
                                              let (_x_1 : fill list) = List.tl fills in
                                              let (_x_2 : int) = count.list count.fill _x_1 in
                                              not Is_a([], fills) && _x_0 >= 0 && _x_2 >= 0
                                              ==> Is_a([], _x_1) || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                          • simplify
                                            into
                                            let (_x_0 : fill list) = List.tl fills in
                                            let (_x_1 : int) = count.list count.fill _x_0 in
                                            let (_x_2 : int) = count.list count.fill fills in
                                            (Is_a([], _x_0) || Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2))
                                            || not ((not Is_a([], fills) && _x_2 >= 0) && _x_1 >= 0)
                                            expansions
                                            []
                                            rewrite_steps
                                              forward_chaining
                                              • unroll
                                                expr
                                                (|`count.list count.fill[0]`_2136| fills_2123)
                                                expansions
                                                • unroll
                                                  expr
                                                  (|`count.list count.fill[0]`_2136| (|get.::.1_2122| fills_2123))
                                                  expansions
                                                  • unroll
                                                    expr
                                                    (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                        (|`count.list count.fill[0]`_2136|
                                                            …
                                                    expansions
                                                    • Unsat

                                                    2.2 Book uncross

                                                    In [5]:
                                                    (* Measure for proving termination of `uncross_book` below *)
                                                    let book_measure b =
                                                      Ordinal.of_int (List.length b.b_buys + List.length b.b_sells)
                                                    
                                                    let rec uncross_book (b : book) (fills : fill list) (filled_qty : int) =
                                                      match b.b_buys, b.b_sells with
                                                      | [], [] | _, [] | [], _ ->
                                                        (* we need to check whether there have been fills before,
                                                          if so we need to adjust fill prices before getting out *)
                                                        begin
                                                          match fills with
                                                          | [] -> { uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty }
                                                          | x::xs ->
                                                            let fills' = x :: (adjust_fill_prices xs x.fill_price) in
                                                          { uncrossed_book = b; uncrossed_fills = fills'; uncrossed_qty = filled_qty }
                                                        end
                                                      | buy::bs, sell::ss ->
                                                        if buy.o_price >= sell.o_price then
                                                          begin
                                                            (* compute the fill qty and price *)
                                                            let fill_qty = if buy.o_qty < sell.o_qty then buy.o_qty else sell.o_qty in
                                                            let fill_price = (buy.o_price + sell.o_price) / 2 in
                                                    
                                                            (* update the orders that traded *)
                                                            let buy' = { buy with o_qty = buy.o_qty - fill_qty } in
                                                            let sell' = { sell with o_qty = sell.o_qty - fill_qty } in
                                                    
                                                            (* create the fills *)
                                                            let fill1 = {
                                                              fill_client_id = buy.o_client_id
                                                              ; fill_qty = fill_qty
                                                              ; fill_price = fill_price
                                                              ; fill_order_id = buy.o_id
                                                              ; fill_order_done = true } in
                                                    
                                                            let fill2 = {
                                                              fill_client_id = sell.o_client_id
                                                              ; fill_qty = fill_qty
                                                              ; fill_price = fill_price
                                                              ; fill_order_id = sell.o_id
                                                              ; fill_order_done = true } in
                                                    
                                                            (* now update the books and fills *)
                                                            let new_buys = if buy'.o_qty = 0 then bs else buy'::bs in
                                                            let new_sells = if sell'.o_qty = 0 then ss else sell'::ss in
                                                            let b' = {
                                                              b_buys = new_buys
                                                              ; b_sells = new_sells } in
                                                    
                                                            (* We should not be generating fills for implied orders - there's
                                                              a different mechanism for that *)
                                                            let fills' = if not buy.o_is_implied then
                                                              fill1 :: fills else fills in
                                                            let fills' = if not sell.o_is_implied then
                                                              fill2 :: fills' else fills' in
                                                    
                                                            (* recursively go to the next level *)
                                                            uncross_book b' fills' (filled_qty + fill_qty)
                                                          end
                                                    
                                                        else
                                                          (* nothing to do here *)
                                                          { uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty }
                                                    [@@measure book_measure b]
                                                    ;;
                                                    
                                                    Out[5]:
                                                    val book_measure : book -> Ordinal.t = <fun>
                                                    val uncross_book : book -> fill list -> int -> uncross_res = <fun>
                                                    
                                                    termination proof

                                                    Termination proof

                                                    call `let (_x_0 : order list) = b.b_buys in let (_x_1 : order) = List.hd _x_0 in let (_x_2 : int) = _x_1.o_qty in let (_x_3 : order list) = b.b_sells in let (_x_4 : order) = List.hd _x_3 in let (_x_5 : int) = _x_4.o_qty in let (_x_6 : int) = if _x_2 < _x_5 then _x_2 else _x_5 in let (_x_7 : int) = _x_2 - _x_6 in let (_x_8 : order list) = List.tl _x_0 in let (_x_9 : int) = _x_5 - _x_6 in let (_x_10 : order list) = List.tl _x_3 in let (_x_11 : int) = (_x_1.o_price + _x_4.o_price) / 2 in let (_x_12 : fill list) = if not _x_1.o_is_implied then {fill_client_id = _x_1.o_client_id; fill_qty = _x_6; fill_price = _x_11; fill_order_id = _x_1.o_id; fill_order_done = true} :: fills else fills in uncross_book {b_buys = if _x_7 = 0 then _x_8 else {_x_1 with o_qty = _x_7} :: _x_8; b_sells = if _x_9 = 0 then _x_10 else {_x_4 with o_qty = _x_9} :: _x_10} (if not _x_4.o_is_implied then {fill_client_id = _x_4.o_client_id; fill_qty = _x_6; fill_price = _x_11; fill_order_id = _x_4.o_id; fill_order_done = true} :: _x_12 else _x_12) (filled_qty + _x_6)` from `uncross_book b fills filled_qty`
                                                    originaluncross_book b fills filled_qty
                                                    sublet (_x_0 : order list) = b.b_buys in let (_x_1 : order) = List.hd _x_0 in let (_x_2 : int) = _x_1.o_qty in let (_x_3 : order list) = b.b_sells in let (_x_4 : order) = List.hd _x_3 in let (_x_5 : int) = _x_4.o_qty in let (_x_6 : int) = if _x_2 < _x_5 then _x_2 else _x_5 in let (_x_7 : int) = _x_2 - _x_6 in let (_x_8 : order list) = List.tl _x_0 in let (_x_9 : int) = _x_5 - _x_6 in let (_x_10 : order list) = List.tl _x_3 in let (_x_11 : int) = (_x_1.o_price + _x_4.o_price) / 2 in let (_x_12 : fill list) = if not _x_1.o_is_implied then {fill_client_id = _x_1.o_client_id; fill_qty = _x_6; fill_price = _x_11; fill_order_id = _x_1.o_id; fill_order_done = true} :: fills else fills in uncross_book {b_buys = if _x_7 = 0 then _x_8 else {_x_1 with o_qty = _x_7} :: _x_8; b_sells = if _x_9 = 0 then _x_10 else {_x_4 with o_qty = _x_9} :: _x_10} (if not _x_4.o_is_implied then {fill_client_id = _x_4.o_client_id; fill_qty = _x_6; fill_price = _x_11; fill_order_id = _x_4.o_id; fill_order_done = true} :: _x_12 else _x_12) (filled_qty + _x_6)
                                                    original ordinalbook_measure b
                                                    sub ordinallet (_x_0 : order list) = b.b_buys in let (_x_1 : order) = List.hd _x_0 in let (_x_2 : int) = _x_1.o_qty in let (_x_3 : order list) = b.b_sells in let (_x_4 : order) = List.hd _x_3 in let (_x_5 : int) = _x_4.o_qty in let (_x_6 : int) = if _x_2 < _x_5 then _x_2 else _x_5 in let (_x_7 : int) = _x_2 - _x_6 in let (_x_8 : order list) = List.tl _x_0 in let (_x_9 : int) = _x_5 - _x_6 in let (_x_10 : order list) = List.tl _x_3 in book_measure {b_buys = if _x_7 = 0 then _x_8 else {_x_1 with o_qty = _x_7} :: _x_8; b_sells = if _x_9 = 0 then _x_10 else {_x_4 with o_qty = _x_9} :: _x_10}
                                                    path[(List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price && not Is_a([], b.b_buys) && not Is_a([], b.b_sells)]
                                                    proof
                                                    detailed proof
                                                    ground_instances5
                                                    definitions0
                                                    inductions0
                                                    search_time
                                                    0.034s
                                                    details
                                                    Expand
                                                    smt_stats
                                                    num checks12
                                                    arith-assume-eqs4
                                                    arith-make-feasible66
                                                    arith-max-columns41
                                                    arith-conflicts4
                                                    rlimit count9668
                                                    arith-cheap-eqs32
                                                    mk clause112
                                                    datatype occurs check85
                                                    mk bool var668
                                                    arith-lower51
                                                    arith-diseq18
                                                    datatype splits144
                                                    decisions145
                                                    arith-propagations5
                                                    propagations147
                                                    interface eqs3
                                                    arith-bound-propagations-cheap5
                                                    arith-max-rows20
                                                    conflicts21
                                                    datatype accessor ax87
                                                    arith-bound-propagations-lp7
                                                    datatype constructor ax229
                                                    num allocs30528266
                                                    final checks14
                                                    added eqs1221
                                                    del clause77
                                                    arith eq adapter54
                                                    arith-upper72
                                                    memory17.620000
                                                    max memory17.620000
                                                    Expand
                                                    • start[0.034s]
                                                        let (_x_0 : order list) = b.b_buys in
                                                        let (_x_1 : order list) = b.b_sells in
                                                        let (_x_2 : order list) = ….b_buys in
                                                        let (_x_3 : order list) = ….b_sells in
                                                        let (_x_4 : int) = List.length _x_2 + List.length _x_3 in
                                                        let (_x_5 : int) = if _x_4 >= 0 then _x_4 else 0 in
                                                        let (_x_6 : int) = List.length ….b_buys + List.length ….b_sells in
                                                        let (_x_7 : int) = if _x_6 >= 0 then _x_6 else 0 in
                                                        let (_x_8 : int) = (List.hd _x_2).o_qty in
                                                        let (_x_9 : int) = (List.hd _x_3).o_qty in
                                                        let (_x_10 : int) = if _x_8 < _x_9 then _x_8 else _x_9 in
                                                        let (_x_11 : int) = _x_8 - _x_10 in
                                                        let (_x_12 : order list) = List.tl _x_2 in
                                                        let (_x_13 : order list)
                                                            = if _x_11 = 0 then _x_12
                                                              else
                                                                {o_qty = _x_11; o_price = …; o_time = …; o_id = …;
                                                                 o_side = …; o_client_id = …; o_inst = …; o_is_implied = …}
                                                                :: _x_12
                                                        in
                                                        let (_x_14 : int) = _x_9 - _x_10 in
                                                        let (_x_15 : order list) = List.tl _x_3 in
                                                        let (_x_16 : order list)
                                                            = if _x_14 = 0 then _x_15
                                                              else
                                                                {o_qty = _x_14; o_price = …; o_time = …; o_id = …;
                                                                 o_side = …; o_client_id = …; o_inst = …; o_is_implied = …}
                                                                :: _x_15
                                                        in
                                                        (List.hd _x_0).o_price >= (List.hd _x_1).o_price
                                                        && not Is_a([], _x_0) && not Is_a([], _x_1) && _x_5 >= 0 && _x_7 >= 0
                                                        ==> not
                                                            ((List.hd _x_13).o_price >= (List.hd _x_16).o_price
                                                             && not Is_a([], _x_13) && not Is_a([], _x_16))
                                                            || Ordinal.( << ) (Ordinal.Int _x_7) (Ordinal.Int _x_5)
                                                    • simplify
                                                      into
                                                      let (_x_0 : order list) = ….b_buys in
                                                      let (_x_1 : int) = (List.hd _x_0).o_qty in
                                                      let (_x_2 : order list) = ….b_sells in
                                                      let (_x_3 : int) = (List.hd _x_2).o_qty in
                                                      let (_x_4 : int) = -1 * (if _x_3 <= _x_1 then _x_3 else _x_1) in
                                                      let (_x_5 : int) = _x_1 + _x_4 in
                                                      let (_x_6 : order list) = List.tl _x_0 in
                                                      let (_x_7 : order list)
                                                          = if _x_5 = 0 then _x_6
                                                            else
                                                              {o_qty = _x_5; o_price = …; o_time = …; o_id = …; o_side = …;
                                                               o_client_id = …; o_inst = …; o_is_implied = …}
                                                              :: _x_6
                                                      in
                                                      let (_x_8 : int) = _x_3 + _x_4 in
                                                      let (_x_9 : order list) = List.tl _x_2 in
                                                      let (_x_10 : order list)
                                                          = if _x_8 = 0 then _x_9
                                                            else
                                                              {o_qty = _x_8; o_price = …; o_time = …; o_id = …; o_side = …;
                                                               o_client_id = …; o_inst = …; o_is_implied = …}
                                                              :: _x_9
                                                      in
                                                      let (_x_11 : int) = List.length _x_7 + List.length _x_10 in
                                                      let (_x_12 : int) = List.length _x_0 + List.length _x_2 in
                                                      (not
                                                       (((List.hd _x_7).o_price >= (List.hd _x_10).o_price && not Is_a([], _x_7))
                                                        && not Is_a([], _x_10))
                                                       || Ordinal.( << ) (Ordinal.Int (if _x_11 >= 0 then _x_11 else 0))
                                                          (Ordinal.Int (if _x_12 >= 0 then _x_12 else 0)))
                                                      || not ((… >= … && not Is_a([], _x_0)) && not Is_a([], _x_2))
                                                      expansions
                                                      []
                                                      rewrite_steps
                                                        forward_chaining
                                                        • unroll
                                                          expr
                                                          (|List.length_2190| (b_sells_87 b_2202))
                                                          expansions
                                                          • unroll
                                                            expr
                                                            (|List.length_2190| (b_buys_86 b_2202))
                                                            expansions
                                                            • unroll
                                                              expr
                                                              (let ((a!1 (<= (o_qty_66 (|get.::.0_2184| (b_sells_87 b_2202)))
                                                                             (o_qty_66 (|get.::.0_…
                                                              expansions
                                                              • unroll
                                                                expr
                                                                (let ((a!1 (<= (o_qty_66 (|get.::.0_2184| (b_sells_87 b_2202)))
                                                                               (o_qty_66 (|get.::.0_…
                                                                expansions
                                                                • unroll
                                                                  expr
                                                                  (let ((a!1 (<= (o_qty_66 (|get.::.0_2184| (b_sells_87 b_2202)))
                                                                                 (o_qty_66 (|get.::.0_…
                                                                  expansions
                                                                  • Unsat

                                                                  We now have a function that does something real - uncross_book (b : book) (fills : fill list) (filled_qty : int). Let's experiment how it works with some concrete values.

                                                                  In [6]:
                                                                  let book1 = {
                                                                    b_buys = [
                                                                      (make BUY 100 55 1 (Outright OUT1) 1 false 1)
                                                                      ; (make BUY 100 50 2 (Outright OUT1) 1 false 1)
                                                                      ]
                                                                   ; b_sells = [
                                                                      (make BUY 100 54 3 (Outright OUT1) 1 false 1)
                                                                      ; (make BUY 100 54 4 (Outright OUT1) 1 false 1)
                                                                    ]
                                                                  } in
                                                                  
                                                                  uncross_book book1 [] 0
                                                                  
                                                                  Out[6]:
                                                                  - : uncross_res =
                                                                  {uncrossed_book =
                                                                    {b_buys =
                                                                      [{o_qty = 100; o_price = 50; o_time = 1; o_id = 2; o_side = BUY;
                                                                        o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
                                                                     b_sells =
                                                                      [{o_qty = 100; o_price = 54; o_time = 1; o_id = 4; o_side = BUY;
                                                                        o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                   uncrossed_fills =
                                                                    [{fill_client_id = 1; fill_qty = 100; fill_price = 54; fill_order_id = 3;
                                                                      fill_order_done = true};
                                                                     {fill_client_id = 1; fill_qty = 100; fill_price = 54; fill_order_id = 1;
                                                                      fill_order_done = true}];
                                                                   uncrossed_qty = 100}
                                                                  

                                                                  2.3 A few verification goals

                                                                  Let's try to verify some verification goals.

                                                                  The first one will make sure that for an order book that is sorted (so the best bid/ask orders will be the first ones in their respective lists. Note: this is not based on the 'imbalance' of the order book, this is simply taking the midpointt of the most aggressive orders.

                                                                  In [7]:
                                                                  (* Returns true if the orders are sorted with respect to price *)
                                                                  let rec side_price_sorted (si : side) (orders : order list) =
                                                                    match orders with
                                                                    | [] -> true
                                                                    | x::[] -> true
                                                                    | x::y::xs ->
                                                                      if si = BUY then
                                                                        begin
                                                                          if y.o_price > x.o_price && x.o_price > 0 then false else (side_price_sorted si (y::xs))
                                                                        end
                                                                      else
                                                                        begin
                                                                          if y.o_price < x.o_price && y.o_price > 0 then false else (side_price_sorted si (y::xs))
                                                                        end
                                                                  ;;
                                                                  
                                                                  (* Let's make sure all the fills have this price *)
                                                                  let rec fills_good_price (fills : fill list) (p : int) =
                                                                    match fills with
                                                                    | [] -> true
                                                                    | x::xs -> (x.fill_price = p) && (fills_good_price xs p)
                                                                  ;;
                                                                  
                                                                  (** Let's to verify some properties *)
                                                                  let fill_price_midpoint (b : book) =
                                                                  
                                                                    let buys_sorted = side_price_sorted BUY b.b_buys in
                                                                    let sells_sorted = side_price_sorted SELL b.b_sells in
                                                                  
                                                                    let result_good =
                                                                      begin
                                                                        match b.b_buys, b.b_sells with
                                                                        | [], _ -> true
                                                                        | _, [] -> true
                                                                        | x::xs, y::ys ->
                                                                          let unc_res = uncross_book b [] 0 in
                                                                          if x.o_price >= y.o_price then
                                                                            let midprice = (x.o_price + y.o_price) / 2 in
                                                                            (List.length unc_res.uncrossed_fills) > 0 && (fills_good_price unc_res.uncrossed_fills midprice)
                                                                          else
                                                                            true
                                                                      end in
                                                                  
                                                                    (* This is the 'punchline'... if the sides are price-sorted, then the fills will be the first midpoint *)
                                                                    (buys_sorted && sells_sorted) ==> result_good
                                                                  ;;
                                                                  
                                                                  
                                                                  verify fill_price_midpoint
                                                                  
                                                                  Out[7]:
                                                                  val side_price_sorted : side -> order list -> bool = <fun>
                                                                  val fills_good_price : fill list -> int -> bool = <fun>
                                                                  val fill_price_midpoint : book -> bool = <fun>
                                                                  - : book -> bool = <fun>
                                                                  module CX : sig val b : book end
                                                                  
                                                                  termination proof

                                                                  Termination proof

                                                                  call `let (_x_0 : order list) = List.tl orders in side_price_sorted si ((List.hd _x_0) :: (List.tl _x_0))` from `side_price_sorted si orders`
                                                                  originalside_price_sorted si orders
                                                                  sublet (_x_0 : order list) = List.tl orders in side_price_sorted si ((List.hd _x_0) :: (List.tl _x_0))
                                                                  original ordinalOrdinal.Int (_cnt orders)
                                                                  sub ordinallet (_x_0 : order list) = List.tl orders in Ordinal.Int (_cnt ((List.hd _x_0) :: (List.tl _x_0)))
                                                                  path[let (_x_0 : int) = (List.hd orders).o_price in not ((List.hd (List.tl orders)).o_price > _x_0 && _x_0 > 0) && si = BUY && not Is_a([], List.tl orders) && not Is_a([], orders)]
                                                                  proof
                                                                  detailed proof
                                                                  ground_instances3
                                                                  definitions0
                                                                  inductions0
                                                                  search_time
                                                                  0.050s
                                                                  details
                                                                  Expand
                                                                  smt_stats
                                                                  num checks8
                                                                  arith-assume-eqs14
                                                                  arith-make-feasible92
                                                                  arith-max-columns66
                                                                  arith-conflicts2
                                                                  rlimit count12989
                                                                  mk clause140
                                                                  datatype occurs check51
                                                                  mk bool var369
                                                                  arith-lower54
                                                                  datatype splits52
                                                                  decisions107
                                                                  propagations89
                                                                  interface eqs14
                                                                  arith-max-rows33
                                                                  conflicts6
                                                                  datatype accessor ax33
                                                                  arith-bound-propagations-lp4
                                                                  datatype constructor ax83
                                                                  num allocs50988240
                                                                  final checks20
                                                                  added eqs438
                                                                  del clause100
                                                                  arith eq adapter48
                                                                  arith-upper81
                                                                  memory20.900000
                                                                  max memory23.440000
                                                                  Expand
                                                                  • start[0.050s]
                                                                      let (_x_0 : order list) = List.tl orders in
                                                                      let (_x_1 : order) = List.hd _x_0 in
                                                                      let (_x_2 : int) = _x_1.o_price in
                                                                      let (_x_3 : int) = (List.hd orders).o_price in
                                                                      let (_x_4 : bool) = si = BUY in
                                                                      let (_x_5 : int) = count.list count.order orders in
                                                                      let (_x_6 : int) = count.list count.order (_x_1 :: …) in
                                                                      let (_x_7 : int) = (List.hd …).o_price in
                                                                      let (_x_8 : bool) = not Is_a([], …) in
                                                                      not (_x_2 > _x_3 && _x_3 > 0)
                                                                      && _x_4
                                                                         && not Is_a([], _x_0) && not Is_a([], orders) && _x_5 >= 0 && _x_6 >= 0
                                                                      ==> not (not (_x_7 > _x_2 && _x_2 > 0) && _x_4 && _x_8)
                                                                          && not (not (_x_7 < _x_2 && _x_7 > 0) && not _x_4 && _x_8)
                                                                          || Ordinal.( << ) (Ordinal.Int _x_6) (Ordinal.Int _x_5)
                                                                  • simplify
                                                                    into
                                                                    let (_x_0 : order list) = List.tl orders in
                                                                    let (_x_1 : order) = List.hd _x_0 in
                                                                    let (_x_2 : int) = count.list count.order (_x_1 :: …) in
                                                                    let (_x_3 : int) = count.list count.order orders in
                                                                    let (_x_4 : int) = (List.hd …).o_price in
                                                                    let (_x_5 : int) = _x_1.o_price in
                                                                    let (_x_6 : bool) = si = BUY in
                                                                    let (_x_7 : bool) = not Is_a([], …) in
                                                                    let (_x_8 : int) = (List.hd orders).o_price in
                                                                    (Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_3)
                                                                     || not ((not (not (_x_4 <= _x_5) && not (_x_5 <= 0)) && _x_6) && _x_7)
                                                                        && not
                                                                           ((not (not (_x_5 <= _x_4) && not (_x_4 <= 0)) && not _x_6) && _x_7))
                                                                    || not
                                                                       (((((not (not (_x_5 <= _x_8) && not (_x_8 <= 0)) && _x_6)
                                                                           && not Is_a([], _x_0))
                                                                          && not Is_a([], orders))
                                                                         && _x_3 >= 0)
                                                                        && _x_2 >= 0)
                                                                    expansions
                                                                    []
                                                                    rewrite_steps
                                                                      forward_chaining
                                                                      • unroll
                                                                        expr
                                                                        (|`count.list count.order[0]`_2414| orders_2400)
                                                                        expansions
                                                                        • unroll
                                                                          expr
                                                                          (|`count.list count.order[0]`_2414|
                                                                            (|::_3| (|get.::.0_2397| (|get.::.1_2398| orders_2400))
                                                                                …
                                                                          expansions
                                                                          • unroll
                                                                            expr
                                                                            (let ((a!1 (|`count.list count.order[0]`_2414|
                                                                                         (|::_3| (|get.::.0_2397| (|get.::.1_2398…
                                                                            expansions
                                                                            • Unsat

                                                                            call `let (_x_0 : order list) = List.tl orders in side_price_sorted si ((List.hd _x_0) :: (List.tl _x_0))` from `side_price_sorted si orders`
                                                                            originalside_price_sorted si orders
                                                                            sublet (_x_0 : order list) = List.tl orders in side_price_sorted si ((List.hd _x_0) :: (List.tl _x_0))
                                                                            original ordinalOrdinal.Int (_cnt orders)
                                                                            sub ordinallet (_x_0 : order list) = List.tl orders in Ordinal.Int (_cnt ((List.hd _x_0) :: (List.tl _x_0)))
                                                                            path[let (_x_0 : int) = (List.hd (List.tl orders)).o_price in not (_x_0 < (List.hd orders).o_price && _x_0 > 0) && not (si = BUY) && not Is_a([], List.tl orders) && not Is_a([], orders)]
                                                                            proof
                                                                            detailed proof
                                                                            ground_instances3
                                                                            definitions0
                                                                            inductions0
                                                                            search_time
                                                                            0.034s
                                                                            details
                                                                            Expand
                                                                            smt_stats
                                                                            num checks8
                                                                            arith-assume-eqs10
                                                                            arith-make-feasible87
                                                                            arith-max-columns61
                                                                            arith-conflicts2
                                                                            rlimit count6432
                                                                            arith-cheap-eqs1
                                                                            mk clause125
                                                                            datatype occurs check51
                                                                            mk bool var368
                                                                            arith-lower56
                                                                            datatype splits56
                                                                            decisions109
                                                                            arith-propagations2
                                                                            propagations84
                                                                            interface eqs10
                                                                            arith-bound-propagations-cheap2
                                                                            arith-max-rows28
                                                                            conflicts8
                                                                            datatype accessor ax36
                                                                            arith-bound-propagations-lp2
                                                                            datatype constructor ax89
                                                                            num allocs37499805
                                                                            final checks16
                                                                            added eqs440
                                                                            del clause85
                                                                            arith eq adapter43
                                                                            arith-upper71
                                                                            memory20.900000
                                                                            max memory20.900000
                                                                            Expand
                                                                            • start[0.034s]
                                                                                let (_x_0 : order list) = List.tl orders in
                                                                                let (_x_1 : order) = List.hd _x_0 in
                                                                                let (_x_2 : int) = _x_1.o_price in
                                                                                let (_x_3 : bool) = _x_2 > 0 in
                                                                                let (_x_4 : bool) = si = BUY in
                                                                                let (_x_5 : bool) = not _x_4 in
                                                                                let (_x_6 : int) = count.list count.order orders in
                                                                                let (_x_7 : int) = count.list count.order (_x_1 :: …) in
                                                                                let (_x_8 : int) = (List.hd …).o_price in
                                                                                let (_x_9 : bool) = not Is_a([], …) in
                                                                                not (_x_2 < (List.hd orders).o_price && _x_3)
                                                                                && _x_5
                                                                                   && not Is_a([], _x_0) && not Is_a([], orders) && _x_6 >= 0 && _x_7 >= 0
                                                                                ==> not (not (_x_8 > _x_2 && _x_3) && _x_4 && _x_9)
                                                                                    && not (not (_x_8 < _x_2 && _x_8 > 0) && _x_5 && _x_9)
                                                                                    || Ordinal.( << ) (Ordinal.Int _x_7) (Ordinal.Int _x_6)
                                                                            • simplify
                                                                              into
                                                                              let (_x_0 : int) = count.list count.order (… :: …) in
                                                                              let (_x_1 : int) = count.list count.order orders in
                                                                              let (_x_2 : int) = (List.hd …).o_price in
                                                                              let (_x_3 : int) = ….o_price in
                                                                              let (_x_4 : bool) = not (_x_3 <= 0) in
                                                                              let (_x_5 : bool) = si = BUY in
                                                                              let (_x_6 : bool) = not Is_a([], …) in
                                                                              let (_x_7 : bool) = not _x_5 in
                                                                              (Ordinal.( << ) (Ordinal.Int _x_0) (Ordinal.Int _x_1)
                                                                               || not ((not (not (_x_2 <= _x_3) && _x_4) && _x_5) && _x_6)
                                                                                  && not ((not (not (_x_3 <= _x_2) && not (_x_2 <= 0)) && _x_7) && _x_6))
                                                                              || not
                                                                                 (((((not (not ((List.hd orders).o_price <= _x_3) && _x_4) && _x_7)
                                                                                     && not Is_a([], List.tl orders))
                                                                                    && not Is_a([], orders))
                                                                                   && _x_1 >= 0)
                                                                                  && _x_0 >= 0)
                                                                              expansions
                                                                              []
                                                                              rewrite_steps
                                                                                forward_chaining
                                                                                • unroll
                                                                                  expr
                                                                                  (|`count.list count.order[0]`_2414| orders_2400)
                                                                                  expansions
                                                                                  • unroll
                                                                                    expr
                                                                                    (|`count.list count.order[0]`_2414|
                                                                                      (|::_3| (|get.::.0_2397| (|get.::.1_2398| orders_2400))
                                                                                          …
                                                                                    expansions
                                                                                    • unroll
                                                                                      expr
                                                                                      (let ((a!1 (|`count.list count.order[0]`_2414|
                                                                                                   (|::_3| (|get.::.0_2397| (|get.::.1_2398…
                                                                                      expansions
                                                                                      • Unsat

                                                                                      termination proof

                                                                                      Termination proof

                                                                                      call `fills_good_price (List.tl fills) p` from `fills_good_price fills p`
                                                                                      originalfills_good_price fills p
                                                                                      subfills_good_price (List.tl fills) p
                                                                                      original ordinalOrdinal.Int (_cnt fills)
                                                                                      sub ordinalOrdinal.Int (_cnt (List.tl fills))
                                                                                      path[(List.hd fills).fill_price = p && not Is_a([], fills)]
                                                                                      proof
                                                                                      detailed proof
                                                                                      ground_instances3
                                                                                      definitions0
                                                                                      inductions0
                                                                                      search_time
                                                                                      0.022s
                                                                                      details
                                                                                      Expand
                                                                                      smt_stats
                                                                                      num checks8
                                                                                      arith-assume-eqs6
                                                                                      arith-make-feasible61
                                                                                      arith-max-columns42
                                                                                      arith-conflicts2
                                                                                      rlimit count3805
                                                                                      mk clause86
                                                                                      datatype occurs check24
                                                                                      mk bool var153
                                                                                      arith-lower36
                                                                                      datatype splits3
                                                                                      decisions49
                                                                                      propagations65
                                                                                      interface eqs6
                                                                                      arith-max-rows18
                                                                                      conflicts8
                                                                                      datatype accessor ax9
                                                                                      datatype constructor ax7
                                                                                      num allocs58635296
                                                                                      final checks12
                                                                                      added eqs116
                                                                                      del clause61
                                                                                      arith eq adapter34
                                                                                      arith-upper58
                                                                                      memory23.850000
                                                                                      max memory23.850000
                                                                                      Expand
                                                                                      • start[0.022s]
                                                                                          let (_x_0 : int) = count.list count.fill fills in
                                                                                          let (_x_1 : fill list) = List.tl fills in
                                                                                          let (_x_2 : int) = count.list count.fill _x_1 in
                                                                                          (List.hd fills).fill_price = p
                                                                                          && not Is_a([], fills) && _x_0 >= 0 && _x_2 >= 0
                                                                                          ==> not ((List.hd _x_1).fill_price = p && not Is_a([], _x_1))
                                                                                              || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                      • simplify
                                                                                        into
                                                                                        let (_x_0 : fill list) = List.tl fills in
                                                                                        let (_x_1 : int) = count.list count.fill _x_0 in
                                                                                        let (_x_2 : int) = count.list count.fill fills in
                                                                                        (not ((List.hd _x_0).fill_price = p && not Is_a([], _x_0))
                                                                                         || Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2))
                                                                                        || not
                                                                                           ((((List.hd fills).fill_price = p && not Is_a([], fills)) && _x_2 >= 0)
                                                                                            && _x_1 >= 0)
                                                                                        expansions
                                                                                        []
                                                                                        rewrite_steps
                                                                                          forward_chaining
                                                                                          • unroll
                                                                                            expr
                                                                                            (|`count.list count.fill[0]`_2571| fills_2558)
                                                                                            expansions
                                                                                            • unroll
                                                                                              expr
                                                                                              (|`count.list count.fill[0]`_2571| (|get.::.1_2557| fills_2558))
                                                                                              expansions
                                                                                              • unroll
                                                                                                expr
                                                                                                (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                    (|`count.list count.fill[0]`_2571|
                                                                                                        …
                                                                                                expansions
                                                                                                • Unsat

                                                                                                Counterexample (after 6 steps, 0.033s):
                                                                                                 let (b : book) =
                                                                                                  {b_buys =
                                                                                                    [{o_qty = 52407; o_price = 0; o_time = 23; o_id = 12; o_side = BUY;
                                                                                                      o_client_id = 13; o_inst = (Strategy (STRAT1)); o_is_implied = true}];
                                                                                                   b_sells =
                                                                                                    [{o_qty = 51264; o_price = 0; o_time = 3; o_id = 4; o_side = BUY;
                                                                                                      o_client_id = 5; o_inst = (Strategy (STRAT1)); o_is_implied = true}]}
                                                                                                
                                                                                                Refuted
                                                                                                proof attempt
                                                                                                ground_instances6
                                                                                                definitions0
                                                                                                inductions0
                                                                                                search_time
                                                                                                0.033s
                                                                                                details
                                                                                                Expand
                                                                                                smt_stats
                                                                                                num checks13
                                                                                                arith-assume-eqs29
                                                                                                arith-make-feasible96
                                                                                                arith-max-columns52
                                                                                                arith-conflicts2
                                                                                                rlimit count14300
                                                                                                arith-cheap-eqs96
                                                                                                mk clause278
                                                                                                datatype occurs check367
                                                                                                mk bool var1012
                                                                                                arith-lower70
                                                                                                arith-diseq10
                                                                                                datatype splits204
                                                                                                decisions282
                                                                                                arith-propagations6
                                                                                                propagations219
                                                                                                interface eqs29
                                                                                                arith-bound-propagations-cheap6
                                                                                                arith-max-rows29
                                                                                                conflicts9
                                                                                                datatype accessor ax129
                                                                                                arith-bound-propagations-lp2
                                                                                                datatype constructor ax310
                                                                                                num allocs76343824
                                                                                                final checks43
                                                                                                added eqs1651
                                                                                                del clause118
                                                                                                arith eq adapter57
                                                                                                arith-upper70
                                                                                                memory24.800000
                                                                                                max memory24.800000
                                                                                                Expand
                                                                                                • start[0.033s]
                                                                                                    let (_x_0 : order list) = ( :var_0: ).b_buys in
                                                                                                    let (_x_1 : order list) = ( :var_0: ).b_sells in
                                                                                                    side_price_sorted BUY _x_0 && side_price_sorted SELL _x_1
                                                                                                    ==> (if Is_a([], _x_0) then true
                                                                                                         else
                                                                                                         if Is_a([], _x_1) then true
                                                                                                         else
                                                                                                         if (List.hd _x_0).o_price >= (List.hd _x_1).o_price
                                                                                                         then List.length … > 0 && fills_good_price … … else true)
                                                                                                • simplify

                                                                                                  into
                                                                                                  let (_x_0 : order list) = ( :var_0: ).b_sells in
                                                                                                  let (_x_1 : order list) = ( :var_0: ).b_buys in
                                                                                                  (((Is_a([], _x_0) || Is_a([], _x_1))
                                                                                                    || not (List.length … <= 0) && fills_good_price … …)
                                                                                                   || not ((List.hd _x_1).o_price >= (List.hd _x_0).o_price))
                                                                                                  || not (side_price_sorted BUY _x_1 && side_price_sorted SELL _x_0)
                                                                                                  expansions
                                                                                                  []
                                                                                                  rewrite_steps
                                                                                                    forward_chaining
                                                                                                    • unroll
                                                                                                      expr
                                                                                                      (side_price_sorted_261 SELL_16 (b_sells_87 b_301))
                                                                                                      expansions
                                                                                                      • unroll
                                                                                                        expr
                                                                                                        (side_price_sorted_261 BUY_15 (b_buys_86 b_301))
                                                                                                        expansions
                                                                                                        • unroll
                                                                                                          expr
                                                                                                          (let ((a!1 (+ (o_price_67 (|get.::.0_2620| (b_buys_86 b_301)))
                                                                                                                        (o_price_67 (|get.::.0_…
                                                                                                          expansions
                                                                                                          • unroll
                                                                                                            expr
                                                                                                            (uncross_book_218 b_301 |[]_2| 0)
                                                                                                            expansions
                                                                                                            • unroll
                                                                                                              expr
                                                                                                              (|List.length_2627| (uncrossed_fills_159 (uncross_book_218 b_301 |[]_2| 0)))
                                                                                                              expansions
                                                                                                              • unroll
                                                                                                                expr
                                                                                                                (let ((a!1 (<= (o_qty_66 (|get.::.0_2620| (b_sells_87 b_301)))
                                                                                                                               (o_qty_66 (|get.::.0_2…
                                                                                                                expansions
                                                                                                                • Sat (Some let (b : book) = {b_buys = [{o_qty = 52407; o_price = 0; o_time = 23; o_id = 12; o_side = BUY; o_client_id = 13; o_inst = (Strategy (STRAT1)); o_is_implied = true}]; b_sells = [{o_qty = 51264; o_price = 0; o_time = 3; o_id = 4; o_side = BUY; o_client_id = 5; o_inst = (Strategy (STRAT1)); o_is_implied = true}]} )

                                                                                                                Our second verification goal will look to make sure that no quantities are lost during uncrossing. Note that no fills are generated for implied orders (there's a different mechanism for that), so when we look at the book we will only consider outright orders. Note that o_qty represents the residual order quantity - for this demo, we do not differentiate between original, filled and residual order quantity. When order is created, the qty is set to that number and is decreased when filled.

                                                                                                                In [8]:
                                                                                                                (* All no quantities get lost during uncross *)
                                                                                                                let no_lost_qtys (b : book) =
                                                                                                                
                                                                                                                  let rec qtys_pos_nonimp = function
                                                                                                                    | [] -> true
                                                                                                                    | x::xs -> x.o_qty >= 0 && not x.o_is_implied && (qtys_pos_nonimp xs) in
                                                                                                                
                                                                                                                  let rec sum_qtys = function
                                                                                                                    | [] -> 0
                                                                                                                    | x::xs -> x.o_qty + (sum_qtys xs) in
                                                                                                                
                                                                                                                  let rec sum_fill_qtys = function
                                                                                                                    | [] -> 0
                                                                                                                    | x::xs -> x.fill_qty + (sum_fill_qtys xs) in
                                                                                                                
                                                                                                                  let unc_res = uncross_book b [] 0 in
                                                                                                                
                                                                                                                  (* We need to make sure the book is non-negative *)
                                                                                                                  let book_nonneg_nonimp = (qtys_pos_nonimp b.b_buys) && (qtys_pos_nonimp b.b_sells) in
                                                                                                                
                                                                                                                  (* Let's sum up all of the quantities of orders before the uncross *)
                                                                                                                  let count_before = (sum_qtys b.b_buys) + (sum_qtys b.b_sells) in
                                                                                                                
                                                                                                                  (* And after *)
                                                                                                                  let count_after = (sum_qtys unc_res.uncrossed_book.b_buys) +
                                                                                                                                    (sum_qtys unc_res.uncrossed_book.b_sells) +
                                                                                                                                    (sum_fill_qtys unc_res.uncrossed_fills) in
                                                                                                                
                                                                                                                  book_nonneg_nonimp ==> (count_before = count_after)
                                                                                                                ;;
                                                                                                                
                                                                                                                verify ~upto:15 no_lost_qtys
                                                                                                                
                                                                                                                Out[8]:
                                                                                                                val no_lost_qtys : book -> bool = <fun>
                                                                                                                - : book -> bool = <fun>
                                                                                                                
                                                                                                                termination proof

                                                                                                                Termination proof

                                                                                                                call `recfun.no_lost_qtys.qtys_pos_nonimp.0 (List.tl _x)` from `recfun.no_lost_qtys.qtys_pos_nonimp.0 _x`
                                                                                                                originalrecfun.no_lost_qtys.qtys_pos_nonimp.0 _x
                                                                                                                subrecfun.no_lost_qtys.qtys_pos_nonimp.0 (List.tl _x)
                                                                                                                original ordinalOrdinal.Int (_cnt _x)
                                                                                                                sub ordinalOrdinal.Int (_cnt (List.tl _x))
                                                                                                                path[not (List.hd _x).o_is_implied && (List.hd _x).o_qty >= 0 && not Is_a([], _x)]
                                                                                                                proof
                                                                                                                detailed proof
                                                                                                                ground_instances3
                                                                                                                definitions0
                                                                                                                inductions0
                                                                                                                search_time
                                                                                                                0.063s
                                                                                                                details
                                                                                                                Expand
                                                                                                                smt_stats
                                                                                                                num checks8
                                                                                                                arith-assume-eqs12
                                                                                                                arith-make-feasible77
                                                                                                                arith-max-columns53
                                                                                                                arith-conflicts2
                                                                                                                rlimit count4806
                                                                                                                mk clause112
                                                                                                                datatype occurs check45
                                                                                                                mk bool var280
                                                                                                                arith-lower42
                                                                                                                datatype splits39
                                                                                                                decisions71
                                                                                                                propagations65
                                                                                                                interface eqs12
                                                                                                                arith-max-rows25
                                                                                                                conflicts6
                                                                                                                datatype accessor ax29
                                                                                                                datatype constructor ax57
                                                                                                                num allocs86499147
                                                                                                                final checks18
                                                                                                                added eqs300
                                                                                                                del clause89
                                                                                                                arith eq adapter40
                                                                                                                arith-upper69
                                                                                                                memory27.910000
                                                                                                                max memory27.910000
                                                                                                                Expand
                                                                                                                • start[0.063s]
                                                                                                                    let (_x_0 : order) = List.hd _x in
                                                                                                                    let (_x_1 : int) = count.list count.order _x in
                                                                                                                    let (_x_2 : int) = count.list count.order … in
                                                                                                                    let (_x_3 : order) = List.hd … in
                                                                                                                    not _x_0.o_is_implied
                                                                                                                    && _x_0.o_qty >= 0 && not Is_a([], _x) && _x_1 >= 0 && _x_2 >= 0
                                                                                                                    ==> not (not _x_3.o_is_implied && _x_3.o_qty >= 0 && not Is_a([], …))
                                                                                                                        || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_1)
                                                                                                                • simplify
                                                                                                                  into
                                                                                                                  let (_x_0 : int) = count.list count.order … in
                                                                                                                  let (_x_1 : int) = count.list count.order _x in
                                                                                                                  let (_x_2 : order) = List.hd … in
                                                                                                                  let (_x_3 : order) = List.hd _x in
                                                                                                                  (Ordinal.( << ) (Ordinal.Int _x_0) (Ordinal.Int _x_1)
                                                                                                                   || not ((not _x_2.o_is_implied && _x_2.o_qty >= 0) && not Is_a([], …)))
                                                                                                                  || not
                                                                                                                     ((((not _x_3.o_is_implied && _x_3.o_qty >= 0) && not Is_a([], _x))
                                                                                                                       && _x_1 >= 0)
                                                                                                                      && _x_0 >= 0)
                                                                                                                  expansions
                                                                                                                  []
                                                                                                                  rewrite_steps
                                                                                                                    forward_chaining
                                                                                                                    • unroll
                                                                                                                      expr
                                                                                                                      (|`count.list count.order[0]`_2778| _x_2767)
                                                                                                                      expansions
                                                                                                                      • unroll
                                                                                                                        expr
                                                                                                                        (|`count.list count.order[0]`_2778| (|get.::.1_2766| _x_2767))
                                                                                                                        expansions
                                                                                                                        • unroll
                                                                                                                          expr
                                                                                                                          (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                              (|`count.list count.order[0]`_2778|
                                                                                                                                 …
                                                                                                                          expansions
                                                                                                                          • Unsat

                                                                                                                          termination proof

                                                                                                                          Termination proof

                                                                                                                          call `recfun.no_lost_qtys.sum_qtys.1 (List.tl _x)` from `recfun.no_lost_qtys.sum_qtys.1 _x`
                                                                                                                          originalrecfun.no_lost_qtys.sum_qtys.1 _x
                                                                                                                          subrecfun.no_lost_qtys.sum_qtys.1 (List.tl _x)
                                                                                                                          original ordinalOrdinal.Int (_cnt _x)
                                                                                                                          sub ordinalOrdinal.Int (_cnt (List.tl _x))
                                                                                                                          path[not Is_a([], _x)]
                                                                                                                          proof
                                                                                                                          detailed proof
                                                                                                                          ground_instances3
                                                                                                                          definitions0
                                                                                                                          inductions0
                                                                                                                          search_time
                                                                                                                          0.055s
                                                                                                                          details
                                                                                                                          Expand
                                                                                                                          smt_stats
                                                                                                                          num checks8
                                                                                                                          arith-assume-eqs5
                                                                                                                          arith-make-feasible34
                                                                                                                          arith-max-columns39
                                                                                                                          arith-conflicts2
                                                                                                                          rlimit count8739
                                                                                                                          mk clause69
                                                                                                                          datatype occurs check39
                                                                                                                          mk bool var223
                                                                                                                          arith-lower17
                                                                                                                          datatype splits35
                                                                                                                          decisions46
                                                                                                                          propagations32
                                                                                                                          interface eqs5
                                                                                                                          arith-max-rows17
                                                                                                                          conflicts6
                                                                                                                          datatype accessor ax28
                                                                                                                          datatype constructor ax57
                                                                                                                          num allocs104913923
                                                                                                                          final checks11
                                                                                                                          added eqs251
                                                                                                                          del clause38
                                                                                                                          arith eq adapter16
                                                                                                                          arith-upper27
                                                                                                                          memory27.840000
                                                                                                                          max memory27.910000
                                                                                                                          Expand
                                                                                                                          • start[0.055s]
                                                                                                                              let (_x_0 : int) = count.list count.order _x in
                                                                                                                              let (_x_1 : order list) = List.tl _x in
                                                                                                                              let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                              not Is_a([], _x) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                              ==> Is_a([], _x_1) || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                          • simplify
                                                                                                                            into
                                                                                                                            let (_x_0 : int) = count.list count.order _x in
                                                                                                                            let (_x_1 : order list) = List.tl _x in
                                                                                                                            let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                            (not ((not Is_a([], _x) && _x_0 >= 0) && _x_2 >= 0)
                                                                                                                             || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0))
                                                                                                                            || Is_a([], _x_1)
                                                                                                                            expansions
                                                                                                                            []
                                                                                                                            rewrite_steps
                                                                                                                              forward_chaining
                                                                                                                              • unroll
                                                                                                                                expr
                                                                                                                                (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                    (|`count.list count.order[0]`_2778|
                                                                                                                                       …
                                                                                                                                expansions
                                                                                                                                • unroll
                                                                                                                                  expr
                                                                                                                                  (|`count.list count.order[0]`_2778| (|get.::.1_2766| _x_2812))
                                                                                                                                  expansions
                                                                                                                                  • unroll
                                                                                                                                    expr
                                                                                                                                    (|`count.list count.order[0]`_2778| _x_2812)
                                                                                                                                    expansions
                                                                                                                                    • Unsat

                                                                                                                                    termination proof

                                                                                                                                    Termination proof

                                                                                                                                    call `recfun.no_lost_qtys.sum_fill_qtys.2 (List.tl _x)` from `recfun.no_lost_qtys.sum_fill_qtys.2 _x`
                                                                                                                                    originalrecfun.no_lost_qtys.sum_fill_qtys.2 _x
                                                                                                                                    subrecfun.no_lost_qtys.sum_fill_qtys.2 (List.tl _x)
                                                                                                                                    original ordinalOrdinal.Int (_cnt _x)
                                                                                                                                    sub ordinalOrdinal.Int (_cnt (List.tl _x))
                                                                                                                                    path[not Is_a([], _x)]
                                                                                                                                    proof
                                                                                                                                    detailed proof
                                                                                                                                    ground_instances3
                                                                                                                                    definitions0
                                                                                                                                    inductions0
                                                                                                                                    search_time
                                                                                                                                    0.046s
                                                                                                                                    details
                                                                                                                                    Expand
                                                                                                                                    smt_stats
                                                                                                                                    num checks8
                                                                                                                                    arith-assume-eqs12
                                                                                                                                    arith-make-feasible77
                                                                                                                                    arith-max-columns51
                                                                                                                                    arith-conflicts2
                                                                                                                                    rlimit count12813
                                                                                                                                    mk clause114
                                                                                                                                    datatype occurs check45
                                                                                                                                    mk bool var176
                                                                                                                                    arith-lower44
                                                                                                                                    datatype splits3
                                                                                                                                    decisions65
                                                                                                                                    propagations73
                                                                                                                                    interface eqs12
                                                                                                                                    arith-max-rows25
                                                                                                                                    conflicts8
                                                                                                                                    datatype accessor ax9
                                                                                                                                    datatype constructor ax7
                                                                                                                                    num allocs115417558
                                                                                                                                    final checks18
                                                                                                                                    added eqs131
                                                                                                                                    del clause87
                                                                                                                                    arith eq adapter42
                                                                                                                                    arith-upper68
                                                                                                                                    memory30.600000
                                                                                                                                    max memory30.600000
                                                                                                                                    Expand
                                                                                                                                    • start[0.046s]
                                                                                                                                        let (_x_0 : int) = count.list count.fill _x in
                                                                                                                                        let (_x_1 : fill list) = List.tl _x in
                                                                                                                                        let (_x_2 : int) = count.list count.fill _x_1 in
                                                                                                                                        not Is_a([], _x) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                                        ==> Is_a([], _x_1) || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                                    • simplify
                                                                                                                                      into
                                                                                                                                      let (_x_0 : fill list) = List.tl _x in
                                                                                                                                      let (_x_1 : int) = count.list count.fill _x_0 in
                                                                                                                                      let (_x_2 : int) = count.list count.fill _x in
                                                                                                                                      (Is_a([], _x_0) || Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2))
                                                                                                                                      || not ((not Is_a([], _x) && _x_2 >= 0) && _x_1 >= 0)
                                                                                                                                      expansions
                                                                                                                                      []
                                                                                                                                      rewrite_steps
                                                                                                                                        forward_chaining
                                                                                                                                        • unroll
                                                                                                                                          expr
                                                                                                                                          (|`count.list count.fill[0]`_2855| _x_2848)
                                                                                                                                          expansions
                                                                                                                                          • unroll
                                                                                                                                            expr
                                                                                                                                            (|`count.list count.fill[0]`_2855| (|get.::.1_2847| _x_2848))
                                                                                                                                            expansions
                                                                                                                                            • unroll
                                                                                                                                              expr
                                                                                                                                              (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                  (|`count.list count.fill[0]`_2855|
                                                                                                                                                      …
                                                                                                                                              expansions
                                                                                                                                              • Unsat

                                                                                                                                              Proved up to 15 steps

                                                                                                                                              2.4 Test generation

                                                                                                                                              First, we will decompose the function and then generate test cases for it.

                                                                                                                                              In [9]:
                                                                                                                                              (* This is a 'side_condition' function that tells decomposition that we're only interested in cases where the
                                                                                                                                              initial fills are empty *)
                                                                                                                                              let cond (b : book) (fills : fill list) (filled_qty : int) =
                                                                                                                                               fills = [] && filled_qty = 0
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              let d = Modular_decomp.top ~assuming:"cond" "uncross_book" ~prune:true [@@program];;
                                                                                                                                              
                                                                                                                                              Out[9]:
                                                                                                                                              val cond : book -> fill list -> int -> bool = <fun>
                                                                                                                                              val d : Modular_decomposition.t =
                                                                                                                                                {Imandra_interactive.Modular_decomp.MD.md_session = 1i;
                                                                                                                                                 md_f =
                                                                                                                                                  {Imandra_surface.Uid.name = "uncross_book"; id = <abstr>;
                                                                                                                                                   special_tag = <abstr>; namespace = <abstr>;
                                                                                                                                                   chash = Some mE5Q46wPGG4H9SmS1ZuNd4hfIpT5QRZwSC1omfx0zwU;
                                                                                                                                                   depth = (3i, 6i)};
                                                                                                                                                 md_args = [(b : book);(fills : fill list);(filled_qty : int)];
                                                                                                                                                 md_regions = <abstr>}
                                                                                                                                              
                                                                                                                                              Regions details

                                                                                                                                              No group selected.

                                                                                                                                              • Concrete regions are numbered
                                                                                                                                              • Unnumbered regions are groups whose children share a particular constraint
                                                                                                                                              • Click on a region to view its details
                                                                                                                                              • Double click on a region to zoom in on it
                                                                                                                                              • Shift+double click to zoom out
                                                                                                                                              • Hit escape to reset back to the top
                                                                                                                                              decomp of (uncross_book b, fills, filled_qty
                                                                                                                                              Reg_idConstraintsInvariant
                                                                                                                                              19
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • Is_a([], fills)
                                                                                                                                              • Is_a([], b.b_buys)
                                                                                                                                              • Is_a([], b.b_sells)
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              18
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • Is_a([], fills)
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • Is_a([], b.b_sells)
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              17
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • Is_a([], fills)
                                                                                                                                              • Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              12
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              let (_x_5 : int) = (_x_3.o_price + _x_2.o_price) / 2 in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl _x_0;
                                                                                                                                               b_sells = {_x_2 with o_qty = _x_2.o_qty - _x_4} :: (List.tl _x_1)}
                                                                                                                                              ({fill_client_id = _x_2.o_client_id; fill_qty = _x_4; fill_price = _x_5;
                                                                                                                                                fill_order_id = _x_2.o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = _x_3.o_client_id; fill_qty = _x_4; fill_price = _x_5;
                                                                                                                                                 fill_order_id = _x_3.o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              11
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl _x_0;
                                                                                                                                               b_sells = {_x_2 with o_qty = _x_2.o_qty - _x_4} :: (List.tl _x_1)}
                                                                                                                                              ({fill_client_id = _x_2.o_client_id; fill_qty = _x_4;
                                                                                                                                                fill_price = (_x_3.o_price + _x_2.o_price) / 2; fill_order_id = _x_2.o_id;
                                                                                                                                                fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              10
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl _x_0;
                                                                                                                                               b_sells = {_x_2 with o_qty = _x_2.o_qty - _x_4} :: (List.tl _x_1)}
                                                                                                                                              ({fill_client_id = _x_3.o_client_id; fill_qty = _x_4;
                                                                                                                                                fill_price = (_x_3.o_price + _x_2.o_price) / 2; fill_order_id = _x_3.o_id;
                                                                                                                                                fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              9
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_sells).o_qty - (List.hd b.b_buys).o_qty = 0)
                                                                                                                                              • (List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : int) = (List.hd _x_0).o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = List.tl _x_0;
                                                                                                                                               b_sells = {_x_2 with o_qty = _x_2.o_qty - _x_3} :: (List.tl _x_1)}
                                                                                                                                              fills (filled_qty + _x_3)
                                                                                                                                              8
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : int) = _x_2.o_qty in
                                                                                                                                              let (_x_4 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_5 : int) = (_x_4.o_price + _x_2.o_price) / 2 in
                                                                                                                                              uncross_book {b_buys = List.tl _x_0; b_sells = List.tl _x_1}
                                                                                                                                              ({fill_client_id = _x_2.o_client_id; fill_qty = _x_3; fill_price = _x_5;
                                                                                                                                                fill_order_id = _x_2.o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = _x_4.o_client_id; fill_qty = _x_3; fill_price = _x_5;
                                                                                                                                                 fill_order_id = _x_4.o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + _x_3)
                                                                                                                                              7
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_3 : int) = _x_2.o_qty in
                                                                                                                                              uncross_book {b_buys = List.tl _x_0; b_sells = List.tl _x_1}
                                                                                                                                              ({fill_client_id = _x_2.o_client_id; fill_qty = _x_3;
                                                                                                                                                fill_price = ((List.hd _x_0).o_price + _x_2.o_price) / 2;
                                                                                                                                                fill_order_id = _x_2.o_id; fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_3)
                                                                                                                                              6
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order list) = b.b_sells in
                                                                                                                                              let (_x_2 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_3 : order) = List.hd _x_1 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              uncross_book {b_buys = List.tl _x_0; b_sells = List.tl _x_1}
                                                                                                                                              ({fill_client_id = _x_2.o_client_id; fill_qty = _x_4;
                                                                                                                                                fill_price = (_x_2.o_price + _x_3.o_price) / 2; fill_order_id = _x_2.o_id;
                                                                                                                                                fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              5
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • (List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_sells in
                                                                                                                                              uncross_book {b_buys = List.tl b.b_buys; b_sells = List.tl _x_0} fills
                                                                                                                                              (filled_qty + (List.hd _x_0).o_qty)
                                                                                                                                              4
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_2 : order list) = b.b_sells in
                                                                                                                                              let (_x_3 : order) = List.hd _x_2 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              let (_x_5 : int) = (_x_1.o_price + _x_3.o_price) / 2 in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = {_x_1 with o_qty = _x_1.o_qty - _x_4} :: (List.tl _x_0);
                                                                                                                                               b_sells = List.tl _x_2}
                                                                                                                                              ({fill_client_id = _x_3.o_client_id; fill_qty = _x_4; fill_price = _x_5;
                                                                                                                                                fill_order_id = _x_3.o_id; fill_order_done = true}
                                                                                                                                               ::
                                                                                                                                               ({fill_client_id = _x_1.o_client_id; fill_qty = _x_4; fill_price = _x_5;
                                                                                                                                                 fill_order_id = _x_1.o_id; fill_order_done = true}
                                                                                                                                                :: fills))
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              3
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • not (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_2 : order list) = b.b_sells in
                                                                                                                                              let (_x_3 : order) = List.hd _x_2 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = {_x_1 with o_qty = _x_1.o_qty - _x_4} :: (List.tl _x_0);
                                                                                                                                               b_sells = List.tl _x_2}
                                                                                                                                              ({fill_client_id = _x_3.o_client_id; fill_qty = _x_4;
                                                                                                                                                fill_price = (_x_1.o_price + _x_3.o_price) / 2; fill_order_id = _x_3.o_id;
                                                                                                                                                fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              2
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_2 : order list) = b.b_sells in
                                                                                                                                              let (_x_3 : order) = List.hd _x_2 in
                                                                                                                                              let (_x_4 : int) = _x_3.o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = {_x_1 with o_qty = _x_1.o_qty - _x_4} :: (List.tl _x_0);
                                                                                                                                               b_sells = List.tl _x_2}
                                                                                                                                              ({fill_client_id = _x_1.o_client_id; fill_qty = _x_4;
                                                                                                                                                fill_price = (_x_1.o_price + _x_3.o_price) / 2; fill_order_id = _x_1.o_id;
                                                                                                                                                fill_order_done = true}
                                                                                                                                               :: fills)
                                                                                                                                              (filled_qty + _x_4)
                                                                                                                                              1
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • (List.hd b.b_buys).o_is_implied
                                                                                                                                              • (List.hd b.b_sells).o_is_implied
                                                                                                                                              • not ((List.hd b.b_buys).o_qty - (List.hd b.b_sells).o_qty = 0)
                                                                                                                                              • not ((List.hd b.b_buys).o_qty < (List.hd b.b_sells).o_qty)
                                                                                                                                              • (List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              let (_x_0 : order list) = b.b_buys in
                                                                                                                                              let (_x_1 : order) = List.hd _x_0 in
                                                                                                                                              let (_x_2 : order list) = b.b_sells in
                                                                                                                                              let (_x_3 : int) = (List.hd _x_2).o_qty in
                                                                                                                                              uncross_book
                                                                                                                                              {b_buys = {_x_1 with o_qty = _x_1.o_qty - _x_3} :: (List.tl _x_0);
                                                                                                                                               b_sells = List.tl _x_2}
                                                                                                                                              fills (filled_qty + _x_3)
                                                                                                                                              0
                                                                                                                                              • fills = []
                                                                                                                                              • filled_qty = 0
                                                                                                                                              • not ((List.hd b.b_buys).o_price >= (List.hd b.b_sells).o_price)
                                                                                                                                              • not Is_a([], b.b_buys)
                                                                                                                                              • not Is_a([], b.b_sells)
                                                                                                                                              {uncrossed_book = b; uncrossed_fills = fills; uncrossed_qty = filled_qty}
                                                                                                                                              In [10]:
                                                                                                                                              (* Now let's try to generate some test cases *)
                                                                                                                                              
                                                                                                                                              (* This will auto-generate model extractor *)
                                                                                                                                              Extract.eval ~quiet:true ~signature:(Event.DB.fun_id_of_str "uncross_book") ();;
                                                                                                                                              
                                                                                                                                              #remove_doc doc_of_book;;
                                                                                                                                              #remove_doc doc_of_order;;
                                                                                                                                              Modular_decomp.get_regions d |> CCList.map (fun r -> r |> Modular_decomp.get_model |> Mex.of_model);;
                                                                                                                                              #install_doc doc_of_order;;
                                                                                                                                              #install_doc doc_of_book;;
                                                                                                                                              
                                                                                                                                              Out[10]:
                                                                                                                                                                                  - : unit = ()
                                                                                                                                              Unbound value doc_pp_doc_of_book.
                                                                                                                                              Unbound value doc_pp_doc_of_book.
                                                                                                                                              Unbound value doc_pp_doc_of_order.
                                                                                                                                              Unbound value doc_pp_doc_of_order.
                                                                                                                                              - : Mex.extract_type list =
                                                                                                                                              [{Mex.b = {b_buys = []; b_sells = []}; fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 3; o_price = 4; o_time = 0; o_id = 1; o_side = BUY;
                                                                                                                                                     o_client_id = 2; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells = []};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys = [];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 2; o_price = 3; o_time = 0; o_id = 4; o_side = BUY;
                                                                                                                                                     o_client_id = 1; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 1; o_price = -7719; o_time = 7; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 1; o_price = -7719; o_time = 7; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 1; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 1; o_price = -7719; o_time = 6; o_id = 7; o_side = BUY;
                                                                                                                                                     o_client_id = 5; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 2; o_id = 1; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 1; o_id = 2; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 2; o_id = 1; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 7719; o_time = 1; o_id = 2; o_side = BUY;
                                                                                                                                                     o_client_id = 3; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = 0; o_price = -38; o_time = 4; o_id = 5; o_side = BUY;
                                                                                                                                                     o_client_id = 6; o_inst = Strategy STRAT1; o_is_implied = true}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = false}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = -1; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};
                                                                                                                                               {Mex.b =
                                                                                                                                                 {b_buys =
                                                                                                                                                   [{o_qty = 0; o_price = 21238; o_time = 2; o_id = 3; o_side = BUY;
                                                                                                                                                     o_client_id = 4; o_inst = Strategy STRAT1; o_is_implied = true}];
                                                                                                                                                  b_sells =
                                                                                                                                                   [{o_qty = -1; o_price = -7719; o_time = 5; o_id = 6; o_side = BUY;
                                                                                                                                                     o_client_id = 7; o_inst = Strategy STRAT1; o_is_implied = false}]};
                                                                                                                                                fills = []; filled_qty = 0};{Mex.b = ...; fills = ...; filled_qty = ...};
                                                                                                                                               ...;...]
                                                                                                                                              Line 2, characters 18-30:
                                                                                                                                              2 |           let d = doc_of_order x in
                                                                                                                                                                    ^^^^^^^^^^^^
                                                                                                                                              Error: Unbound value doc_of_order
                                                                                                                                              Line 2, characters 18-29:
                                                                                                                                              2 |           let d = doc_of_book x in
                                                                                                                                                                    ^^^^^^^^^^^
                                                                                                                                              Error: Unbound value doc_of_book
                                                                                                                                              

                                                                                                                                              3 Implied trading

                                                                                                                                              3.1 Strategy ranking

                                                                                                                                              When generating implied orders for strategies, there's a criteria used to rank strategies - this section encodes the comparison function.

                                                                                                                                              In [11]:
                                                                                                                                              (* Calculate somehow how big the ratio is *)
                                                                                                                                              let leg_ratio (s : strategy) =
                                                                                                                                                let abs x = if x < 0 then -x else x in
                                                                                                                                                (abs s.leg1.leg_mult) + (abs s.leg2.leg_mult) + (abs s.leg3.leg_mult)
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              (* Nearest time to expiry *)
                                                                                                                                              let nearest_time_to_exp (s : strategy) =
                                                                                                                                                let exp =
                                                                                                                                                  if (month_to_int (contract_expiry s.leg1.leg_sec_idx)) < (month_to_int (contract_expiry s.leg2.leg_sec_idx)) then
                                                                                                                                                    contract_expiry s.leg1.leg_sec_idx
                                                                                                                                                  else
                                                                                                                                                    contract_expiry s.leg2.leg_sec_idx in
                                                                                                                                              
                                                                                                                                                if (month_to_int exp) < (month_to_int (contract_expiry s.leg2.leg_sec_idx)) then
                                                                                                                                                  exp
                                                                                                                                                else
                                                                                                                                                  contract_expiry s.leg2.leg_sec_idx
                                                                                                                                              ;;
                                                                                                                                              
                                                                                                                                              (* Return true if s1 should implied uncross before s2 *)
                                                                                                                                              let priority_strat (s1 : strategy) (s2 : strategy) =
                                                                                                                                                (*
                                                                                                                                                  1. time to expiry of the nearest leg
                                                                                                                                                  2. strategy types (strategies with the greater leg ratio executed first)
                                                                                                                                                  3. strategy creation times *)
                                                                                                                                                if (month_to_int (nearest_time_to_exp s1)) < (month_to_int (nearest_time_to_exp s2)) then
                                                                                                                                                  true
                                                                                                                                                else
                                                                                                                                                  if (leg_ratio s1) > (leg_ratio s2) then
                                                                                                                                                    true
                                                                                                                                                  else
                                                                                                                                                    s1.time_created <= s2.time_created
                                                                                                                                              
                                                                                                                                              Out[11]:
                                                                                                                                              val leg_ratio : strategy -> int = <fun>
                                                                                                                                              val nearest_time_to_exp : strategy -> month = <fun>
                                                                                                                                              val priority_strat : strategy -> strategy -> bool = <fun>
                                                                                                                                              
                                                                                                                                              In [12]:
                                                                                                                                              let transitivity s1 s2 s3 =
                                                                                                                                               ((priority_strat s1 s2) && (priority_strat s2 s3)) ==> (priority_strat s1 s3)
                                                                                                                                              
                                                                                                                                              verify transitivity
                                                                                                                                              
                                                                                                                                              Out[12]:
                                                                                                                                              val transitivity : strategy -> strategy -> strategy -> bool = <fun>
                                                                                                                                              - : strategy -> strategy -> strategy -> bool = <fun>
                                                                                                                                              module CX : sig val s1 : strategy val s2 : strategy val s3 : strategy end
                                                                                                                                              
                                                                                                                                              Counterexample (after 0 steps, 0.035s):
                                                                                                                                               let (s1 : strategy) =
                                                                                                                                                {time_created = 0; leg1 = {leg_sec_idx = OUT2; leg_mult = 1};
                                                                                                                                                 leg2 = {leg_sec_idx = OUT3; leg_mult = 0};
                                                                                                                                                 leg3 = {leg_sec_idx = OUT1; leg_mult = 0}}
                                                                                                                                               let (s2 : strategy) =
                                                                                                                                                {time_created = 26285; leg1 = {leg_sec_idx = OUT3; leg_mult = 0};
                                                                                                                                                 leg2 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                 leg3 = {leg_sec_idx = OUT1; leg_mult = 0}}
                                                                                                                                               let (s3 : strategy) =
                                                                                                                                                {time_created = (-1); leg1 = {leg_sec_idx = OUT3; leg_mult = 0};
                                                                                                                                                 leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                 leg3 = {leg_sec_idx = OUT1; leg_mult = (-8946)}}
                                                                                                                                              
                                                                                                                                              Refuted
                                                                                                                                              proof attempt
                                                                                                                                              ground_instances0
                                                                                                                                              definitions0
                                                                                                                                              inductions0
                                                                                                                                              search_time
                                                                                                                                              0.036s
                                                                                                                                              details
                                                                                                                                              Expand
                                                                                                                                              smt_stats
                                                                                                                                              num checks1
                                                                                                                                              arith-assume-eqs7
                                                                                                                                              arith-make-feasible284
                                                                                                                                              arith-max-columns75
                                                                                                                                              arith-conflicts5
                                                                                                                                              rlimit count18935
                                                                                                                                              arith-cheap-eqs48
                                                                                                                                              mk clause488
                                                                                                                                              datatype occurs check42
                                                                                                                                              mk bool var784
                                                                                                                                              arith-lower186
                                                                                                                                              arith-diseq44
                                                                                                                                              datatype splits121
                                                                                                                                              decisions502
                                                                                                                                              arith-propagations84
                                                                                                                                              propagations667
                                                                                                                                              interface eqs7
                                                                                                                                              arith-bound-propagations-cheap84
                                                                                                                                              arith-max-rows41
                                                                                                                                              conflicts26
                                                                                                                                              datatype accessor ax52
                                                                                                                                              minimized lits10
                                                                                                                                              arith-bound-propagations-lp8
                                                                                                                                              datatype constructor ax144
                                                                                                                                              num allocs1267977029
                                                                                                                                              final checks8
                                                                                                                                              added eqs1291
                                                                                                                                              del clause168
                                                                                                                                              arith eq adapter182
                                                                                                                                              arith-upper291
                                                                                                                                              memory35.110000
                                                                                                                                              max memory67.160000
                                                                                                                                              Expand
                                                                                                                                              • start[0.036s]
                                                                                                                                                  let (_x_0 : int) = ( :var_0: ).time_created in
                                                                                                                                                  let (_x_1 : int) = ( :var_1: ).time_created in
                                                                                                                                                  let (_x_2 : int) = ( :var_0: ).leg1.leg_mult in
                                                                                                                                                  let (_x_3 : int) = ( :var_0: ).leg2.leg_mult in
                                                                                                                                                  let (_x_4 : int) = ( :var_0: ).leg3.leg_mult in
                                                                                                                                                  let (_x_5 : int)
                                                                                                                                                      = (if _x_2 < 0 then ~- _x_2 else _x_2)
                                                                                                                                                        + (if _x_3 < 0 then ~- _x_3 else _x_3)
                                                                                                                                                        + (if _x_4 < 0 then ~- _x_4 else _x_4)
                                                                                                                                                  in
                                                                                                                                                  let (_x_6 : int) = ( :var_1: ).leg1.leg_mult in
                                                                                                                                                  let (_x_7 : int) = ( :var_1: ).leg2.leg_mult in
                                                                                                                                                  let (_x_8 : int) = ( :var_1: ).leg3.leg_mult in
                                                                                                                                                  let (_x_9 : int)
                                                                                                                                                      = (if _x_6 < 0 then ~- _x_6 else _x_6)
                                                                                                                                                        + (if _x_7 < 0 then ~- _x_7 else _x_7)
                                                                                                                                                        + (if _x_8 < 0 then ~- _x_8 else _x_8)
                                                                                                                                                  in
                                                                                                                                                  let (_x_10 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_11 : bool) = Is_a(Jun, …) in
                                                                                                                                                  let (_x_12 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_13 : bool) = Is_a(Mar, if _x_12 then … else …) in
                                                                                                                                                  let (_x_14 : bool)
                                                                                                                                                      = (if Is_a(Mar, if _x_10 then … else …) then 3
                                                                                                                                                         else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                        < (if _x_13 then 3 else if _x_11 then 6 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_15 : bool)
                                                                                                                                                      = (if Is_a(Mar,
                                                                                                                                                            if _x_14 then if _x_10 then … else …
                                                                                                                                                            else if _x_12 then … else …)
                                                                                                                                                         then 3
                                                                                                                                                         else
                                                                                                                                                         if Is_a(Jun, if _x_14 then … else …) then 6
                                                                                                                                                         else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                        <
                                                                                                                                                        (if _x_13 then 3
                                                                                                                                                         else if _x_11 then 6 else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                  in
                                                                                                                                                  let (_x_16 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_17 : bool) = Is_a(Jun, …) in
                                                                                                                                                  let (_x_18 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_19 : bool) = Is_a(Mar, if _x_18 then … else …) in
                                                                                                                                                  let (_x_20 : bool)
                                                                                                                                                      = (if Is_a(Mar, if _x_16 then … else …) then 3
                                                                                                                                                         else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                        < (if _x_19 then 3 else if _x_17 then 6 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_21 : bool)
                                                                                                                                                      = (if Is_a(Mar,
                                                                                                                                                            if _x_20 then if _x_16 then … else …
                                                                                                                                                            else if _x_18 then … else …)
                                                                                                                                                         then 3
                                                                                                                                                         else
                                                                                                                                                         if Is_a(Jun, if _x_20 then … else …) then 6
                                                                                                                                                         else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                        <
                                                                                                                                                        (if _x_19 then 3
                                                                                                                                                         else if _x_17 then 6 else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                  in
                                                                                                                                                  let (_x_22 : int)
                                                                                                                                                      = if Is_a(Mar,
                                                                                                                                                           if _x_21
                                                                                                                                                           then
                                                                                                                                                             if _x_20 then if _x_16 then … else …
                                                                                                                                                             else if _x_18 then … else …
                                                                                                                                                           else if _x_18 then … else if Is_a(OUT2, …) then … else …)
                                                                                                                                                        then 3
                                                                                                                                                        else
                                                                                                                                                        if Is_a(Jun,
                                                                                                                                                           if _x_21 then if _x_20 then … else …
                                                                                                                                                           else if _x_18 then … else …)
                                                                                                                                                        then 6 else if Is_a(Sep, if _x_21 then … else …) then 9 else 12
                                                                                                                                                  in
                                                                                                                                                  let (_x_23 : int) = ( :var_2: ).time_created in
                                                                                                                                                  let (_x_24 : int) = ( :var_2: ).leg1.leg_mult in
                                                                                                                                                  let (_x_25 : int) = ….leg_mult in
                                                                                                                                                  let (_x_26 : int) = ( :var_2: ).leg3.leg_mult in
                                                                                                                                                  let (_x_27 : int)
                                                                                                                                                      = (if _x_24 < 0 then ~- _x_24 else _x_24)
                                                                                                                                                        + (if _x_25 < 0 then ~- _x_25 else _x_25)
                                                                                                                                                        + (if _x_26 < 0 then ~- _x_26 else _x_26)
                                                                                                                                                  in
                                                                                                                                                  let (_x_28 : bool) = Is_a(Mar, …) in
                                                                                                                                                  let (_x_29 : bool)
                                                                                                                                                      = (if Is_a(Mar, …) then 3 else …) < (if _x_28 then 3 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_30 : bool)
                                                                                                                                                      = (if Is_a(Mar, if _x_29 then … else …) then 3
                                                                                                                                                         else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                        < (if _x_28 then 3 else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_31 : outright_id) = ….leg_sec_idx in
                                                                                                                                                  let (_x_32 : bool) = Is_a(OUT1, _x_31) in
                                                                                                                                                  let (_x_33 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_34 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_35 : bool) = Is_a(Jun, …) in
                                                                                                                                                  let (_x_36 : bool) = Is_a(Mar, if _x_33 then … else …) in
                                                                                                                                                  let (_x_37 : bool)
                                                                                                                                                      = (if Is_a(Mar, if _x_34 then … else …) then 3
                                                                                                                                                         else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                        < (if _x_36 then 3 else if _x_35 then 6 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_38 : int)
                                                                                                                                                      = if Is_a(Mar,
                                                                                                                                                           if (if Is_a(Mar,
                                                                                                                                                                  if _x_37 then if _x_34 then … else …
                                                                                                                                                                  else if _x_33 then … else …)
                                                                                                                                                               then 3
                                                                                                                                                               else
                                                                                                                                                               if Is_a(Jun, if _x_37 then … else …) then 6
                                                                                                                                                               else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                              <
                                                                                                                                                              (if _x_36 then 3
                                                                                                                                                               else if _x_35 then 6 else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                           then
                                                                                                                                                             if _x_37 then if _x_34 then … else …
                                                                                                                                                             else if _x_33 then … else …
                                                                                                                                                           else if _x_32 then Mar else if Is_a(OUT2, _x_31) then … else …)
                                                                                                                                                        then 3
                                                                                                                                                        else
                                                                                                                                                        if Is_a(Jun,
                                                                                                                                                           if _x_30 then if _x_29 then … else …
                                                                                                                                                           else if _x_32 then Mar else …)
                                                                                                                                                        then 6 else if Is_a(Sep, if _x_30 then … else …) then 9 else 12
                                                                                                                                                  in
                                                                                                                                                  let (_x_39 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_40 : bool) = Is_a(Jun, …) in
                                                                                                                                                  let (_x_41 : bool) = Is_a(OUT1, …) in
                                                                                                                                                  let (_x_42 : bool) = Is_a(Mar, if _x_41 then Mar else …) in
                                                                                                                                                  let (_x_43 : bool)
                                                                                                                                                      = (if Is_a(Mar, if _x_39 then Mar else …) then 3
                                                                                                                                                         else if Is_a(Jun, …) then 6 else …)
                                                                                                                                                        < (if _x_42 then 3 else if _x_40 then 6 else …)
                                                                                                                                                  in
                                                                                                                                                  let (_x_44 : bool)
                                                                                                                                                      = (if Is_a(Mar,
                                                                                                                                                            if _x_43 then if _x_39 then Mar else …
                                                                                                                                                            else if _x_41 then Mar else …)
                                                                                                                                                         then 3
                                                                                                                                                         else
                                                                                                                                                         if Is_a(Jun, if _x_43 then … else …) then 6
                                                                                                                                                         else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                        <
                                                                                                                                                        (if _x_42 then 3
                                                                                                                                                         else if _x_40 then 6 else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                  in
                                                                                                                                                  (if (if Is_a(Mar,
                                                                                                                                                          if _x_15
                                                                                                                                                          then
                                                                                                                                                            if _x_14 then if _x_10 then … else …
                                                                                                                                                            else if _x_12 then … else …
                                                                                                                                                          else if _x_12 then … else if Is_a(OUT2, …) then … else …)
                                                                                                                                                       then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun,
                                                                                                                                                          if _x_15 then if _x_14 then … else …
                                                                                                                                                          else if _x_12 then … else …)
                                                                                                                                                       then 6 else if Is_a(Sep, if _x_15 then … else …) then 9 else 12)
                                                                                                                                                      < _x_22
                                                                                                                                                   then true else if _x_5 > _x_9 then true else _x_0 <= _x_1)
                                                                                                                                                  && (if _x_22 < _x_38 then true
                                                                                                                                                      else if _x_9 > _x_27 then true else _x_1 <= _x_23)
                                                                                                                                                  ==> (if (if Is_a(Mar,
                                                                                                                                                              if _x_44
                                                                                                                                                              then
                                                                                                                                                                if _x_43 then if _x_39 then Mar else …
                                                                                                                                                                else if _x_41 then Mar else …
                                                                                                                                                              else
                                                                                                                                                              if _x_41 then Mar else if Is_a(OUT2, …) then … else …)
                                                                                                                                                           then 3
                                                                                                                                                           else
                                                                                                                                                           if Is_a(Jun,
                                                                                                                                                              if _x_44 then if _x_43 then … else …
                                                                                                                                                              else if _x_41 then Mar else …)
                                                                                                                                                           then 6
                                                                                                                                                           else if Is_a(Sep, if _x_44 then … else …) then 9 else 12)
                                                                                                                                                          < _x_38
                                                                                                                                                       then true else if _x_5 > _x_27 then true else _x_0 <= _x_23)
                                                                                                                                              • simplify

                                                                                                                                                into
                                                                                                                                                let (_x_0 : int) = ( :var_0: ).time_created in
                                                                                                                                                let (_x_1 : int) = ( :var_2: ).time_created in
                                                                                                                                                let (_x_2 : bool) = Is_a(OUT1, ….leg_sec_idx) in
                                                                                                                                                let (_x_3 : month)
                                                                                                                                                    = if _x_2 then Mar else if Is_a(OUT2, …) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_4 : int)
                                                                                                                                                    = if Is_a(Mar, _x_3) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun, if _x_2 then Mar else …) then 6
                                                                                                                                                      else if Is_a(Sep, …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_5 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_6 : bool) = Is_a(OUT1, _x_5) in
                                                                                                                                                let (_x_7 : month)
                                                                                                                                                    = if _x_6 then Mar else if Is_a(OUT2, _x_5) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_8 : bool)
                                                                                                                                                    = _x_4 <=
                                                                                                                                                      (if Is_a(Mar, _x_7) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun, if _x_6 then Mar else …) then 6
                                                                                                                                                       else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_9 : bool)
                                                                                                                                                    = _x_8
                                                                                                                                                      || _x_4 <=
                                                                                                                                                         (if Is_a(Mar,
                                                                                                                                                             if _x_8 then if _x_2 then Mar else …
                                                                                                                                                             else if _x_6 then Mar else …)
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if Is_a(Jun, if _x_8 then … else …) then 6
                                                                                                                                                          else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_10 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_11 : bool) = Is_a(OUT1, _x_10) in
                                                                                                                                                let (_x_12 : month)
                                                                                                                                                    = if _x_11 then Mar else if Is_a(OUT2, _x_10) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_13 : int)
                                                                                                                                                    = if Is_a(Mar, _x_12) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun, if _x_11 then Mar else …) then 6
                                                                                                                                                      else if Is_a(Sep, …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_14 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_15 : bool) = Is_a(OUT1, _x_14) in
                                                                                                                                                let (_x_16 : month)
                                                                                                                                                    = if _x_15 then Mar else if Is_a(OUT2, _x_14) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_17 : bool)
                                                                                                                                                    = _x_13 <=
                                                                                                                                                      (if Is_a(Mar, _x_16) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun, if _x_15 then Mar else …) then 6
                                                                                                                                                       else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_18 : bool)
                                                                                                                                                    = _x_17
                                                                                                                                                      || _x_13 <=
                                                                                                                                                         (if Is_a(Mar,
                                                                                                                                                             if _x_17 then if _x_11 then Mar else …
                                                                                                                                                             else if _x_15 then Mar else …)
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if Is_a(Jun, if _x_17 then … else …) then 6
                                                                                                                                                          else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_19 : int) = ….leg_mult in
                                                                                                                                                let (_x_20 : int) = ….leg_mult in
                                                                                                                                                let (_x_21 : int) = ( :var_0: ).leg3.leg_mult in
                                                                                                                                                let (_x_22 : int) = if 0 <= _x_21 then _x_21 else -1 * _x_21 in
                                                                                                                                                let (_x_23 : leg) = ( :var_2: ).leg1 in
                                                                                                                                                let (_x_24 : int) = ….leg_mult in
                                                                                                                                                let (_x_25 : int) = ( :var_2: ).leg2.leg_mult in
                                                                                                                                                let (_x_26 : int) = ( :var_2: ).leg3.leg_mult in
                                                                                                                                                let (_x_27 : int)
                                                                                                                                                    = (if 0 <= _x_24 then _x_24 else -1 * _x_23.leg_mult)
                                                                                                                                                      + (if 0 <= _x_25 then _x_25 else -1 * _x_25)
                                                                                                                                                      + (if 0 <= _x_26 then _x_26 else -1 * _x_26)
                                                                                                                                                in
                                                                                                                                                let (_x_28 : int) = ( :var_1: ).time_created in
                                                                                                                                                let (_x_29 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_30 : bool) = Is_a(OUT1, _x_29) in
                                                                                                                                                let (_x_31 : month)
                                                                                                                                                    = if _x_30 then Mar else if Is_a(OUT2, _x_29) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_32 : int)
                                                                                                                                                    = if Is_a(Mar, _x_31) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun, if _x_30 then Mar else …) then 6
                                                                                                                                                      else if Is_a(Sep, …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_33 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_34 : bool) = Is_a(OUT1, _x_33) in
                                                                                                                                                let (_x_35 : month)
                                                                                                                                                    = if _x_34 then Mar else if Is_a(OUT2, _x_33) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_36 : bool)
                                                                                                                                                    = _x_32 <=
                                                                                                                                                      (if Is_a(Mar, _x_35) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun, if _x_34 then Mar else …) then 6
                                                                                                                                                       else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_37 : bool)
                                                                                                                                                    = _x_36
                                                                                                                                                      || _x_32 <=
                                                                                                                                                         (if Is_a(Mar,
                                                                                                                                                             if _x_36 then if _x_30 then Mar else …
                                                                                                                                                             else if _x_34 then Mar else …)
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if Is_a(Jun, if _x_36 then … else …) then 6
                                                                                                                                                          else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_38 : int)
                                                                                                                                                    = if Is_a(Mar, if _x_37 then _x_31 else _x_35) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun,
                                                                                                                                                         if _x_37 then if _x_30 then Mar else …
                                                                                                                                                         else if _x_34 then Mar else …)
                                                                                                                                                      then 6 else if Is_a(Sep, if _x_37 then … else …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_39 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_40 : bool) = Is_a(OUT1, _x_39) in
                                                                                                                                                let (_x_41 : month)
                                                                                                                                                    = if _x_40 then Mar else if Is_a(OUT2, _x_39) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_42 : int)
                                                                                                                                                    = if Is_a(Mar, _x_41) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun, if _x_40 then Mar else …) then 6
                                                                                                                                                      else if Is_a(Sep, …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_43 : outright_id) = ….leg_sec_idx in
                                                                                                                                                let (_x_44 : bool) = Is_a(OUT1, _x_43) in
                                                                                                                                                let (_x_45 : month)
                                                                                                                                                    = if _x_44 then Mar else if Is_a(OUT2, _x_43) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_46 : bool)
                                                                                                                                                    = _x_42 <=
                                                                                                                                                      (if Is_a(Mar, _x_45) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun, if _x_44 then Mar else …) then 6
                                                                                                                                                       else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_47 : bool)
                                                                                                                                                    = _x_46
                                                                                                                                                      || _x_42 <=
                                                                                                                                                         (if Is_a(Mar,
                                                                                                                                                             if _x_46 then if _x_40 then Mar else …
                                                                                                                                                             else if _x_44 then Mar else …)
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if Is_a(Jun, if _x_46 then … else …) then 6
                                                                                                                                                          else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_48 : int) = ….leg_mult in
                                                                                                                                                let (_x_49 : int) = ….leg_mult in
                                                                                                                                                let (_x_50 : int) = ….leg_mult in
                                                                                                                                                let (_x_51 : int) = ….leg_mult in
                                                                                                                                                let (_x_52 : int) = ( :var_1: ).leg3.leg_mult in
                                                                                                                                                let (_x_53 : int)
                                                                                                                                                    = (if 0 <= _x_50 then _x_50 else -1 * _x_50)
                                                                                                                                                      + (if 0 <= _x_51 then _x_51 else -1 * _x_51)
                                                                                                                                                      + (if 0 <= _x_52 then _x_52 else -1 * _x_52)
                                                                                                                                                in
                                                                                                                                                let (_x_54 : month)
                                                                                                                                                    = if _x_2 then Mar else if Is_a(OUT2, …) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_55 : int)
                                                                                                                                                    = if Is_a(Mar, _x_54) then 3
                                                                                                                                                      else
                                                                                                                                                      if Is_a(Jun, if _x_2 then Mar else …) then 6
                                                                                                                                                      else if Is_a(Sep, …) then 9 else 12
                                                                                                                                                in
                                                                                                                                                let (_x_56 : outright_id) = _x_23.leg_sec_idx in
                                                                                                                                                let (_x_57 : bool) = Is_a(OUT1, _x_56) in
                                                                                                                                                let (_x_58 : month)
                                                                                                                                                    = if _x_57 then Mar else if Is_a(OUT2, _x_56) then … else …
                                                                                                                                                in
                                                                                                                                                let (_x_59 : bool)
                                                                                                                                                    = _x_55 <=
                                                                                                                                                      (if Is_a(Mar, _x_58) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun, if _x_57 then Mar else …) then 6
                                                                                                                                                       else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                let (_x_60 : bool)
                                                                                                                                                    = _x_59
                                                                                                                                                      || _x_55 <=
                                                                                                                                                         (if Is_a(Mar,
                                                                                                                                                             if _x_59 then if _x_2 then Mar else …
                                                                                                                                                             else if _x_57 then Mar else …)
                                                                                                                                                          then 3
                                                                                                                                                          else
                                                                                                                                                          if Is_a(Jun, if _x_59 then … else …) then 6
                                                                                                                                                          else if Is_a(Sep, …) then 9 else 12)
                                                                                                                                                in
                                                                                                                                                ((_x_0 <= _x_1
                                                                                                                                                  || not
                                                                                                                                                     ((if Is_a(Mar, if _x_9 then _x_3 else _x_7) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun,
                                                                                                                                                          if _x_9 then if _x_2 then Mar else …
                                                                                                                                                          else if _x_6 then Mar else …)
                                                                                                                                                       then 6 else if Is_a(Sep, if _x_9 then … else …) then 9 else 12)
                                                                                                                                                      <=
                                                                                                                                                      (if Is_a(Mar, if _x_18 then _x_12 else _x_16) then 3
                                                                                                                                                       else
                                                                                                                                                       if Is_a(Jun,
                                                                                                                                                          if _x_18 then if _x_11 then Mar else …
                                                                                                                                                          else if _x_15 then Mar else …)
                                                                                                                                                       then 6 else if Is_a(Sep, if _x_18 then … else …) then 9 else 12)))
                                                                                                                                                 || not
                                                                                                                                                    (((if 0 <= _x_19 then _x_19 else -1 * _x_19)
                                                                                                                                                      + (if 0 <= _x_20 then _x_20 else -1 * _x_20) + _x_22)
                                                                                                                                                     <= _x_27))
                                                                                                                                                || not
                                                                                                                                                   (((_x_0 <= _x_28
                                                                                                                                                      || not
                                                                                                                                                         (_x_38 <=
                                                                                                                                                          (if Is_a(Mar, if _x_47 then _x_41 else _x_45) then 3
                                                                                                                                                           else
                                                                                                                                                           if Is_a(Jun,
                                                                                                                                                              if _x_47 then if _x_40 then Mar else …
                                                                                                                                                              else if _x_44 then Mar else …)
                                                                                                                                                           then 6
                                                                                                                                                           else if Is_a(Sep, if _x_47 then … else …) then 9 else 12)))
                                                                                                                                                     || not
                                                                                                                                                        (((if 0 <= _x_48 then _x_48 else -1 * _x_48)
                                                                                                                                                          + (if 0 <= _x_49 then _x_49 else -1 * _x_49) + _x_22)
                                                                                                                                                         <= _x_53))
                                                                                                                                                    && ((_x_28 <= _x_1
                                                                                                                                                         || not
                                                                                                                                                            ((if Is_a(Mar, if _x_60 then _x_54 else _x_58) then 3
                                                                                                                                                              else
                                                                                                                                                              if Is_a(Jun,
                                                                                                                                                                 if _x_60 then if _x_2 then Mar else …
                                                                                                                                                                 else if _x_57 then Mar else …)
                                                                                                                                                              then 6
                                                                                                                                                              else if Is_a(Sep, if _x_60 then … else …) then 9 else 12)
                                                                                                                                                             <= _x_38))
                                                                                                                                                        || not (_x_53 <= _x_27)))
                                                                                                                                                expansions
                                                                                                                                                []
                                                                                                                                                rewrite_steps
                                                                                                                                                  forward_chaining
                                                                                                                                                  • Sat (Some let (s1 : strategy) = {time_created = 0; leg1 = {leg_sec_idx = OUT2; leg_mult = 1}; leg2 = {leg_sec_idx = OUT3; leg_mult = 0}; leg3 = {leg_sec_idx = OUT1; leg_mult = 0}} let (s2 : strategy) = {time_created = 26285; leg1 = {leg_sec_idx = OUT3; leg_mult = 0}; leg2 = {leg_sec_idx = OUT1; leg_mult = 0}; leg3 = {leg_sec_idx = OUT1; leg_mult = 0}} let (s3 : strategy) = {time_created = (-1); leg1 = {leg_sec_idx = OUT3; leg_mult = 0}; leg2 = {leg_sec_idx = OUT2; leg_mult = 0}; leg3 = {leg_sec_idx = OUT1; leg_mult = (-8946)}} )

                                                                                                                                                  Ooops! It seems that our ranking criteria is not transitive. Let's check the results (note that the counter examples are now reflected into the run time in the CX module)

                                                                                                                                                  In [13]:
                                                                                                                                                  priority_strat CX.s1 CX.s2
                                                                                                                                                  
                                                                                                                                                  Out[13]:
                                                                                                                                                  - : bool = true
                                                                                                                                                  
                                                                                                                                                  In [14]:
                                                                                                                                                  priority_strat CX.s2 CX.s3
                                                                                                                                                  
                                                                                                                                                  Out[14]:
                                                                                                                                                  - : bool = true
                                                                                                                                                  
                                                                                                                                                  In [15]:
                                                                                                                                                  priority_strat CX.s1 CX.s3
                                                                                                                                                  
                                                                                                                                                  Out[15]:
                                                                                                                                                  - : bool = false
                                                                                                                                                  

                                                                                                                                                  3.2 Implied strategy price calculation

                                                                                                                                                  In [16]:
                                                                                                                                                  (* return the sum of volume at the highest level *)
                                                                                                                                                  let rec get_level_sums (orders : order list) (li : level_info option) =
                                                                                                                                                    match orders with
                                                                                                                                                    | [] -> li
                                                                                                                                                    | x::xs ->
                                                                                                                                                      begin
                                                                                                                                                        match li with
                                                                                                                                                        | None -> get_level_sums xs (Some {li_qty = x.o_qty; li_price = x.o_price})
                                                                                                                                                        | Some l ->
                                                                                                                                                          if (l.li_price = x.o_price) then
                                                                                                                                                            get_level_sums xs (Some {l with li_qty = l.li_qty + x.o_qty})
                                                                                                                                                          else
                                                                                                                                                            li
                                                                                                                                                      end
                                                                                                                                                  
                                                                                                                                                  (* Return best bid/ask levels *)
                                                                                                                                                  let get_book_tops (b : book) =
                                                                                                                                                    let bid_info = get_level_sums b.b_buys None in
                                                                                                                                                    let ask_info = get_level_sums b.b_sells None in
                                                                                                                                                    { bid_info; ask_info }
                                                                                                                                                  ;;
                                                                                                                                                  
                                                                                                                                                  (* Get the maximum number of strategy units here *)
                                                                                                                                                  (* Note that the units may have different signs, so we
                                                                                                                                                   need to make sure that we have enough *)
                                                                                                                                                  let calc_implied_strat_order (sid : strategy_id) (s : strategy) (books : books_info) (si : side) (time : int) =
                                                                                                                                                    let abs x = if x < 0 then -x else x in
                                                                                                                                                  
                                                                                                                                                    let adjust (mult : int) =
                                                                                                                                                      if si = BUY then mult else -mult in
                                                                                                                                                  
                                                                                                                                                    (* *)
                                                                                                                                                    let calc_max_out_mult (mult : int) (book : best_bid_ask)  =
                                                                                                                                                      if mult = 0 then
                                                                                                                                                        None
                                                                                                                                                      else
                                                                                                                                                        begin
                                                                                                                                                         if (adjust mult) > 0 then
                                                                                                                                                          match books.book1.bid_info with
                                                                                                                                                             | Some x -> Some (x.li_qty / (abs mult))
                                                                                                                                                             | None -> None
                                                                                                                                                         else
                                                                                                                                                             match book.ask_info with
                                                                                                                                                             | Some x -> Some (x.li_qty / (abs mult))
                                                                                                                                                             | None -> None
                                                                                                                                                        end in
                                                                                                                                                  
                                                                                                                                                    let mult1 = calc_max_out_mult s.leg1.leg_mult books.book1 in
                                                                                                                                                    let mult2 = calc_max_out_mult s.leg2.leg_mult books.book2 in
                                                                                                                                                    let mult3 = calc_max_out_mult s.leg3.leg_mult books.book3 in
                                                                                                                                                  
                                                                                                                                                    (* Compute the quantity *)
                                                                                                                                                    let max_strat =
                                                                                                                                                      begin
                                                                                                                                                         match mult1 with
                                                                                                                                                         | None -> 0
                                                                                                                                                         | Some x -> x
                                                                                                                                                      end in
                                                                                                                                                    let max_strat =
                                                                                                                                                      begin
                                                                                                                                                         match mult2 with
                                                                                                                                                         | None -> max_strat
                                                                                                                                                         | Some x -> if x < max_strat then x else max_strat
                                                                                                                                                      end in
                                                                                                                                                    let max_strat =
                                                                                                                                                      begin
                                                                                                                                                       match mult3 with
                                                                                                                                                       | None -> max_strat
                                                                                                                                                       | Some x -> if x < max_strat then x else max_strat
                                                                                                                                                      end in
                                                                                                                                                  
                                                                                                                                                    (* Now compute the price *)
                                                                                                                                                    let strat_price =
                                                                                                                                                      begin
                                                                                                                                                         match mult1 with
                                                                                                                                                         | None -> 0
                                                                                                                                                         | Some x ->
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg1.leg_mult) > 0 then
                                                                                                                                                                  match books.book1.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg1.leg_mult)
                                                                                                                                                                  | None -> 0
                                                                                                                                                              else
                                                                                                                                                                  match books.book1.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg1.leg_mult)
                                                                                                                                                                  | None -> 0
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                    let strat_price =
                                                                                                                                                      begin
                                                                                                                                                         match mult2 with
                                                                                                                                                         | None -> strat_price
                                                                                                                                                         | Some x ->
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg2.leg_mult) > 0 then
                                                                                                                                                                  match books.book2.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg2.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                              else
                                                                                                                                                                  match books.book2.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg2.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                    let strat_price =
                                                                                                                                                      begin
                                                                                                                                                         match mult3 with
                                                                                                                                                         | None -> strat_price
                                                                                                                                                         | Some x ->
                                                                                                                                                           begin
                                                                                                                                                              if (adjust s.leg3.leg_mult) > 0 then
                                                                                                                                                                  match books.book3.bid_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg3.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                              else
                                                                                                                                                                  match books.book3.ask_info with
                                                                                                                                                                  | Some x -> x.li_price * (adjust s.leg3.leg_mult) + strat_price
                                                                                                                                                                  | None -> strat_price
                                                                                                                                                           end
                                                                                                                                                      end in
                                                                                                                                                  
                                                                                                                                                    (* Now form the new implied order here... *)
                                                                                                                                                    {
                                                                                                                                                     o_qty = max_strat
                                                                                                                                                     ; o_price = strat_price
                                                                                                                                                     ; o_id = -1
                                                                                                                                                     ; o_time = time
                                                                                                                                                     ; o_side = si
                                                                                                                                                     ; o_client_id = -1
                                                                                                                                                     ; o_inst = Strategy sid
                                                                                                                                                     ; o_is_implied = true }
                                                                                                                                                  ;;
                                                                                                                                                  
                                                                                                                                                  Out[16]:
                                                                                                                                                  val get_level_sums : order list -> level_info option -> level_info option =
                                                                                                                                                    <fun>
                                                                                                                                                  val get_book_tops : book -> best_bid_ask = <fun>
                                                                                                                                                  val calc_implied_strat_order :
                                                                                                                                                    strategy_id -> strategy -> books_info -> side -> int -> order = <fun>
                                                                                                                                                  
                                                                                                                                                  termination proof

                                                                                                                                                  Termination proof

                                                                                                                                                  call `let (_x_0 : order) = List.hd orders in get_level_sums (List.tl orders) (Some {li_qty = _x_0.o_qty; li_price = _x_0.o_price})` from `get_level_sums orders li`
                                                                                                                                                  originalget_level_sums orders li
                                                                                                                                                  sublet (_x_0 : order) = List.hd orders in get_level_sums (List.tl orders) (Some {li_qty = _x_0.o_qty; li_price = _x_0.o_price})
                                                                                                                                                  original ordinalOrdinal.Int (_cnt orders)
                                                                                                                                                  sub ordinalOrdinal.Int (_cnt (List.tl orders))
                                                                                                                                                  path[Is_a(None, li) && not Is_a([], orders)]
                                                                                                                                                  proof
                                                                                                                                                  detailed proof
                                                                                                                                                  ground_instances3
                                                                                                                                                  definitions0
                                                                                                                                                  inductions0
                                                                                                                                                  search_time
                                                                                                                                                  0.016s
                                                                                                                                                  details
                                                                                                                                                  Expand
                                                                                                                                                  smt_stats
                                                                                                                                                  num checks8
                                                                                                                                                  arith-assume-eqs10
                                                                                                                                                  arith-make-feasible65
                                                                                                                                                  arith-max-columns51
                                                                                                                                                  arith-conflicts2
                                                                                                                                                  rlimit count9554
                                                                                                                                                  mk clause103
                                                                                                                                                  datatype occurs check51
                                                                                                                                                  mk bool var272
                                                                                                                                                  arith-lower37
                                                                                                                                                  datatype splits39
                                                                                                                                                  decisions69
                                                                                                                                                  propagations67
                                                                                                                                                  interface eqs10
                                                                                                                                                  arith-max-rows23
                                                                                                                                                  conflicts6
                                                                                                                                                  datatype accessor ax30
                                                                                                                                                  datatype constructor ax58
                                                                                                                                                  num allocs1377949698
                                                                                                                                                  final checks16
                                                                                                                                                  added eqs304
                                                                                                                                                  del clause74
                                                                                                                                                  arith eq adapter35
                                                                                                                                                  arith-upper59
                                                                                                                                                  memory38.110000
                                                                                                                                                  max memory67.160000
                                                                                                                                                  Expand
                                                                                                                                                  • start[0.016s]
                                                                                                                                                      let (_x_0 : int) = count.list count.order orders in
                                                                                                                                                      let (_x_1 : order list) = List.tl orders in
                                                                                                                                                      let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                                                      Is_a(None, li) && not Is_a([], orders) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                                                      ==> not
                                                                                                                                                          ((List.hd orders).o_price = (List.hd _x_1).o_price
                                                                                                                                                           && not Is_a([], _x_1))
                                                                                                                                                          || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                                                  • simplify
                                                                                                                                                    into
                                                                                                                                                    let (_x_0 : order list) = List.tl orders in
                                                                                                                                                    let (_x_1 : int) = count.list count.order _x_0 in
                                                                                                                                                    let (_x_2 : int) = count.list count.order orders in
                                                                                                                                                    (Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2)
                                                                                                                                                     || not
                                                                                                                                                        ((List.hd orders).o_price = (List.hd _x_0).o_price && not Is_a([], _x_0)))
                                                                                                                                                    || not (((Is_a(None, li) && not Is_a([], orders)) && _x_2 >= 0) && _x_1 >= 0)
                                                                                                                                                    expansions
                                                                                                                                                    []
                                                                                                                                                    rewrite_steps
                                                                                                                                                      forward_chaining
                                                                                                                                                      • unroll
                                                                                                                                                        expr
                                                                                                                                                        (|`count.list count.order[0]`_3734| orders_3719)
                                                                                                                                                        expansions
                                                                                                                                                        • unroll
                                                                                                                                                          expr
                                                                                                                                                          (|`count.list count.order[0]`_3734| (|get.::.1_3715| orders_3719))
                                                                                                                                                          expansions
                                                                                                                                                          • unroll
                                                                                                                                                            expr
                                                                                                                                                            (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                                (|`count.list count.order[0]`_3734|
                                                                                                                                                                   …
                                                                                                                                                            expansions
                                                                                                                                                            • Unsat

                                                                                                                                                            call `let (_x_0 : level_info) = Option.get li in get_level_sums (List.tl orders) (Some {_x_0 with li_qty = _x_0.li_qty + (List.hd orders).o_qty})` from `get_level_sums orders li`
                                                                                                                                                            originalget_level_sums orders li
                                                                                                                                                            sublet (_x_0 : level_info) = Option.get li in get_level_sums (List.tl orders) (Some {_x_0 with li_qty = _x_0.li_qty + (List.hd orders).o_qty})
                                                                                                                                                            original ordinalOrdinal.Int (_cnt orders)
                                                                                                                                                            sub ordinalOrdinal.Int (_cnt (List.tl orders))
                                                                                                                                                            path[(Option.get li).li_price = (List.hd orders).o_price && not Is_a(None, li) && not Is_a([], orders)]
                                                                                                                                                            proof
                                                                                                                                                            detailed proof
                                                                                                                                                            ground_instances3
                                                                                                                                                            definitions0
                                                                                                                                                            inductions0
                                                                                                                                                            search_time
                                                                                                                                                            0.019s
                                                                                                                                                            details
                                                                                                                                                            Expand
                                                                                                                                                            smt_stats
                                                                                                                                                            num checks8
                                                                                                                                                            arith-assume-eqs14
                                                                                                                                                            arith-make-feasible71
                                                                                                                                                            arith-max-columns55
                                                                                                                                                            arith-conflicts2
                                                                                                                                                            rlimit count4857
                                                                                                                                                            mk clause116
                                                                                                                                                            datatype occurs check67
                                                                                                                                                            mk bool var284
                                                                                                                                                            arith-lower38
                                                                                                                                                            datatype splits39
                                                                                                                                                            decisions76
                                                                                                                                                            propagations62
                                                                                                                                                            interface eqs14
                                                                                                                                                            arith-max-rows27
                                                                                                                                                            conflicts6
                                                                                                                                                            datatype accessor ax31
                                                                                                                                                            datatype constructor ax59
                                                                                                                                                            num allocs1342472444
                                                                                                                                                            final checks20
                                                                                                                                                            added eqs311
                                                                                                                                                            del clause87
                                                                                                                                                            arith eq adapter36
                                                                                                                                                            arith-upper57
                                                                                                                                                            memory35.360000
                                                                                                                                                            max memory67.160000
                                                                                                                                                            Expand
                                                                                                                                                            • start[0.019s]
                                                                                                                                                                let (_x_0 : int) = (Option.get li).li_price in
                                                                                                                                                                let (_x_1 : int) = count.list count.order orders in
                                                                                                                                                                let (_x_2 : order list) = List.tl orders in
                                                                                                                                                                let (_x_3 : int) = count.list count.order _x_2 in
                                                                                                                                                                _x_0 = (List.hd orders).o_price
                                                                                                                                                                && not Is_a(None, li) && not Is_a([], orders) && _x_1 >= 0 && _x_3 >= 0
                                                                                                                                                                ==> not (_x_0 = (List.hd _x_2).o_price && not Is_a([], _x_2))
                                                                                                                                                                    || Ordinal.( << ) (Ordinal.Int _x_3) (Ordinal.Int _x_1)
                                                                                                                                                            • simplify
                                                                                                                                                              into
                                                                                                                                                              let (_x_0 : int) = (Option.get li).li_price in
                                                                                                                                                              let (_x_1 : order list) = List.tl orders in
                                                                                                                                                              let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                                                              let (_x_3 : int) = count.list count.order orders in
                                                                                                                                                              (not (_x_0 = (List.hd _x_1).o_price && not Is_a([], _x_1))
                                                                                                                                                               || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_3))
                                                                                                                                                              || not
                                                                                                                                                                 ((((_x_0 = (List.hd orders).o_price && not Is_a(None, li))
                                                                                                                                                                    && not Is_a([], orders))
                                                                                                                                                                   && _x_3 >= 0)
                                                                                                                                                                  && _x_2 >= 0)
                                                                                                                                                              expansions
                                                                                                                                                              []
                                                                                                                                                              rewrite_steps
                                                                                                                                                                forward_chaining
                                                                                                                                                                • unroll
                                                                                                                                                                  expr
                                                                                                                                                                  (|`count.list count.order[0]`_3734| orders_3719)
                                                                                                                                                                  expansions
                                                                                                                                                                  • unroll
                                                                                                                                                                    expr
                                                                                                                                                                    (|`count.list count.order[0]`_3734| (|get.::.1_3715| orders_3719))
                                                                                                                                                                    expansions
                                                                                                                                                                    • unroll
                                                                                                                                                                      expr
                                                                                                                                                                      (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                                          (|`count.list count.order[0]`_3734|
                                                                                                                                                                             …
                                                                                                                                                                      expansions
                                                                                                                                                                      • Unsat

                                                                                                                                                                      Let's now try to experiment with this.

                                                                                                                                                                      In [17]:
                                                                                                                                                                      let strat1 = {
                                                                                                                                                                        time_created = 1;
                                                                                                                                                                        leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                        ; leg2  = { leg_sec_idx = OUT2; leg_mult = 0 }
                                                                                                                                                                        ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      let books = {
                                                                                                                                                                          book1 = { bid_info = None ; ask_info = Some { li_qty = 100 ; li_price = 450 }}
                                                                                                                                                                        ; book2 = { bid_info = Some { li_qty = 125 ; li_price = 100 }; ask_info = Some { li_qty = 100 ; li_price = 350 }}
                                                                                                                                                                        ; book3 = { bid_info = None ; ask_info = Some { li_qty = 100 ; li_price = 425 }}
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      (* This should just replicate the OUT1 security on the SELL side *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat1 books SELL 1
                                                                                                                                                                      
                                                                                                                                                                      Out[17]:
                                                                                                                                                                      val strat1 : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      val books : books_info =
                                                                                                                                                                        {book1 = {bid_info = None; ask_info = Some {li_qty = 100; li_price = 450}};
                                                                                                                                                                         book2 =
                                                                                                                                                                          {bid_info = Some {li_qty = 125; li_price = 100};
                                                                                                                                                                           ask_info = Some {li_qty = 100; li_price = 350}};
                                                                                                                                                                         book3 = {bid_info = None; ask_info = Some {li_qty = 100; li_price = 425}}}
                                                                                                                                                                      - : order =
                                                                                                                                                                      {o_qty = 100; o_price = -450; o_time = 1; o_id = -1; o_side = SELL;
                                                                                                                                                                       o_client_id = -1; o_inst = Strategy STRAT1; o_is_implied = true}
                                                                                                                                                                      
                                                                                                                                                                      In [18]:
                                                                                                                                                                      (* Now let's try the same on the BUY side - there should not be any available orders as the bid is empty *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat1 books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[18]:
                                                                                                                                                                      - : order =
                                                                                                                                                                      {o_qty = 0; o_price = 0; o_time = 1; o_id = -1; o_side = BUY;
                                                                                                                                                                       o_client_id = -1; o_inst = Strategy STRAT1; o_is_implied = true}
                                                                                                                                                                      
                                                                                                                                                                      In [19]:
                                                                                                                                                                      (* let's try to mix up the legs now *)
                                                                                                                                                                      
                                                                                                                                                                      let strat2 = {
                                                                                                                                                                       strat1 with
                                                                                                                                                                       leg2 = {leg_sec_idx = OUT2; leg_mult = -1}
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      (* This will not result in any orders because there's no BUY *)
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat2 books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[19]:
                                                                                                                                                                      val strat2 : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      - : order =
                                                                                                                                                                      {o_qty = 0; o_price = -350; o_time = 1; o_id = -1; o_side = BUY;
                                                                                                                                                                       o_client_id = -1; o_inst = Strategy STRAT1; o_is_implied = true}
                                                                                                                                                                      
                                                                                                                                                                      In [20]:
                                                                                                                                                                      calc_implied_strat_order STRAT2 strat2 books SELL 1
                                                                                                                                                                      
                                                                                                                                                                      Out[20]:
                                                                                                                                                                      - : order =
                                                                                                                                                                      {o_qty = 100; o_price = -450; o_time = 1; o_id = -1; o_side = SELL;
                                                                                                                                                                       o_client_id = -1; o_inst = Strategy STRAT2; o_is_implied = true}
                                                                                                                                                                      
                                                                                                                                                                      In [21]:
                                                                                                                                                                      let strat = {
                                                                                                                                                                        time_created = 1;
                                                                                                                                                                        leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                        ; leg2  = { leg_sec_idx = OUT2; leg_mult = -2 }
                                                                                                                                                                        ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      let books = {
                                                                                                                                                                          book1 = { bid_info = Some { li_qty = 500; li_price = 50 } ; ask_info = Some { li_qty = 750 ; li_price = 50 }}
                                                                                                                                                                        ; book2 = { bid_info = Some { li_qty = 200 ; li_price = 60 }; ask_info = Some { li_qty = 500 ; li_price = 70 }}
                                                                                                                                                                        ; book3 = { bid_info = None ; ask_info = None }
                                                                                                                                                                      };;
                                                                                                                                                                      
                                                                                                                                                                      calc_implied_strat_order STRAT1 strat books BUY 1
                                                                                                                                                                      
                                                                                                                                                                      Out[21]:
                                                                                                                                                                      val strat : strategy =
                                                                                                                                                                        {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                         leg2 = {leg_sec_idx = OUT2; leg_mult = -2};
                                                                                                                                                                         leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                      val books : books_info =
                                                                                                                                                                        {book1 =
                                                                                                                                                                          {bid_info = Some {li_qty = 500; li_price = 50};
                                                                                                                                                                           ask_info = Some {li_qty = 750; li_price = 50}};
                                                                                                                                                                         book2 =
                                                                                                                                                                          {bid_info = Some {li_qty = 200; li_price = 60};
                                                                                                                                                                           ask_info = Some {li_qty = 500; li_price = 70}};
                                                                                                                                                                         book3 = {bid_info = None; ask_info = None}}
                                                                                                                                                                      - : order =
                                                                                                                                                                      {o_qty = 250; o_price = -90; o_time = 1; o_id = -1; o_side = BUY;
                                                                                                                                                                       o_client_id = -1; o_inst = Strategy STRAT1; o_is_implied = true}
                                                                                                                                                                      

                                                                                                                                                                      3.3 Implied uncrossing operations

                                                                                                                                                                      In [22]:
                                                                                                                                                                      (* removes implied orders from a book *)
                                                                                                                                                                      let remove_imp_orders (b : book) =
                                                                                                                                                                        let rec remove_imp_orders_side (orders : order list) =
                                                                                                                                                                          match orders with
                                                                                                                                                                          | [] -> []
                                                                                                                                                                          | x::xs ->
                                                                                                                                                                              if x.o_is_implied then
                                                                                                                                                                                (remove_imp_orders_side xs)
                                                                                                                                                                              else
                                                                                                                                                                                x::(remove_imp_orders_side xs) in
                                                                                                                                                                      
                                                                                                                                                                        { b_buys = (remove_imp_orders_side b.b_buys)
                                                                                                                                                                        ; b_sells = (remove_imp_orders_side b.b_sells)
                                                                                                                                                                        }
                                                                                                                                                                      
                                                                                                                                                                      (* Allocate implied fills to the book and return fills *)
                                                                                                                                                                      let allocate_implied_fills (b : book) (qty : int) (price : int) (time : int) =
                                                                                                                                                                        if qty = 0 then {
                                                                                                                                                                          uncrossed_book = b
                                                                                                                                                                          ; uncrossed_fills = []
                                                                                                                                                                          ; uncrossed_qty = 0
                                                                                                                                                                        } else
                                                                                                                                                                        begin
                                                                                                                                                                          (* Insert new order into the book and uncross it *)
                                                                                                                                                                          let new_order = {
                                                                                                                                                                            o_qty = if qty < 0 then (-qty) else qty
                                                                                                                                                                            ; o_price = price
                                                                                                                                                                            ; o_id = -1
                                                                                                                                                                            ; o_time = time
                                                                                                                                                                            ; o_side = if qty < 0 then SELL else BUY
                                                                                                                                                                            ; o_client_id = -1
                                                                                                                                                                            ; o_inst = Outright OUT1
                                                                                                                                                                            ; o_is_implied = true
                                                                                                                                                                          } in
                                                                                                                                                                      
                                                                                                                                                                          (* create new order that we will trade *)
                                                                                                                                                                          let b' = insert_order new_order b in
                                                                                                                                                                      
                                                                                                                                                                          (* finally we will uncross the book and return results *)
                                                                                                                                                                          (uncross_book b' [] 0)
                                                                                                                                                                        end
                                                                                                                                                                      
                                                                                                                                                                      (* Calculate the price at which implied orders should trade in the outright books *)
                                                                                                                                                                      let calc_implied_trade_price (mult : int) (bidask : best_bid_ask) =
                                                                                                                                                                        if mult > 0 then
                                                                                                                                                                         begin
                                                                                                                                                                          match bidask.ask_info with
                                                                                                                                                                            | None -> 0
                                                                                                                                                                            | Some x -> x.li_price
                                                                                                                                                                          end
                                                                                                                                                                        else
                                                                                                                                                                          begin
                                                                                                                                                                              match bidask.bid_info with
                                                                                                                                                                                | None -> 0
                                                                                                                                                                                | Some x -> x.li_price
                                                                                                                                                                          end
                                                                                                                                                                      ;;
                                                                                                                                                                      
                                                                                                                                                                      Out[22]:
                                                                                                                                                                      val remove_imp_orders : book -> book = <fun>
                                                                                                                                                                      val allocate_implied_fills : book -> int -> int -> int -> uncross_res = <fun>
                                                                                                                                                                      val calc_implied_trade_price : int -> best_bid_ask -> int = <fun>
                                                                                                                                                                      
                                                                                                                                                                      termination proof

                                                                                                                                                                      Termination proof

                                                                                                                                                                      call `recfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)` from `recfun.remove_imp_orders.remove_imp_orders_side.0 orders`
                                                                                                                                                                      originalrecfun.remove_imp_orders.remove_imp_orders_side.0 orders
                                                                                                                                                                      subrecfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)
                                                                                                                                                                      original ordinalOrdinal.Int (_cnt orders)
                                                                                                                                                                      sub ordinalOrdinal.Int (_cnt (List.tl orders))
                                                                                                                                                                      path[(List.hd orders).o_is_implied && not Is_a([], orders)]
                                                                                                                                                                      proof
                                                                                                                                                                      detailed proof
                                                                                                                                                                      ground_instances3
                                                                                                                                                                      definitions0
                                                                                                                                                                      inductions0
                                                                                                                                                                      search_time
                                                                                                                                                                      0.028s
                                                                                                                                                                      details
                                                                                                                                                                      Expand
                                                                                                                                                                      smt_stats
                                                                                                                                                                      num checks8
                                                                                                                                                                      arith-assume-eqs15
                                                                                                                                                                      arith-make-feasible87
                                                                                                                                                                      arith-max-columns60
                                                                                                                                                                      arith-conflicts2
                                                                                                                                                                      rlimit count9956
                                                                                                                                                                      mk clause141
                                                                                                                                                                      datatype occurs check54
                                                                                                                                                                      mk bool var317
                                                                                                                                                                      arith-lower50
                                                                                                                                                                      datatype splits39
                                                                                                                                                                      decisions86
                                                                                                                                                                      propagations99
                                                                                                                                                                      interface eqs15
                                                                                                                                                                      arith-max-rows30
                                                                                                                                                                      conflicts7
                                                                                                                                                                      datatype accessor ax32
                                                                                                                                                                      datatype constructor ax61
                                                                                                                                                                      num allocs1545708943
                                                                                                                                                                      final checks21
                                                                                                                                                                      added eqs338
                                                                                                                                                                      del clause107
                                                                                                                                                                      arith eq adapter48
                                                                                                                                                                      arith-upper80
                                                                                                                                                                      memory39.720000
                                                                                                                                                                      max memory67.160000
                                                                                                                                                                      Expand
                                                                                                                                                                      • start[0.028s]
                                                                                                                                                                          let (_x_0 : int) = count.list count.order orders in
                                                                                                                                                                          let (_x_1 : order list) = List.tl orders in
                                                                                                                                                                          let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                                                                          let (_x_3 : bool) = (List.hd _x_1).o_is_implied in
                                                                                                                                                                          let (_x_4 : bool) = not Is_a([], _x_1) in
                                                                                                                                                                          (List.hd orders).o_is_implied
                                                                                                                                                                          && not Is_a([], orders) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                                                                          ==> not (_x_3 && _x_4) && not (not _x_3 && _x_4)
                                                                                                                                                                              || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                                                                      • simplify
                                                                                                                                                                        into
                                                                                                                                                                        let (_x_0 : order list) = List.tl orders in
                                                                                                                                                                        let (_x_1 : bool) = (List.hd _x_0).o_is_implied in
                                                                                                                                                                        let (_x_2 : bool) = not Is_a([], _x_0) in
                                                                                                                                                                        let (_x_3 : int) = count.list count.order _x_0 in
                                                                                                                                                                        let (_x_4 : int) = count.list count.order orders in
                                                                                                                                                                        (not (_x_1 && _x_2) && not (not _x_1 && _x_2)
                                                                                                                                                                         || Ordinal.( << ) (Ordinal.Int _x_3) (Ordinal.Int _x_4))
                                                                                                                                                                        || not
                                                                                                                                                                           ((((List.hd orders).o_is_implied && not Is_a([], orders)) && _x_4 >= 0)
                                                                                                                                                                            && _x_3 >= 0)
                                                                                                                                                                        expansions
                                                                                                                                                                        []
                                                                                                                                                                        rewrite_steps
                                                                                                                                                                          forward_chaining
                                                                                                                                                                          • unroll
                                                                                                                                                                            expr
                                                                                                                                                                            (|`count.list count.order[0]`_3876| orders_3863)
                                                                                                                                                                            expansions
                                                                                                                                                                            • unroll
                                                                                                                                                                              expr
                                                                                                                                                                              (|`count.list count.order[0]`_3876| (|get.::.1_3862| orders_3863))
                                                                                                                                                                              expansions
                                                                                                                                                                              • unroll
                                                                                                                                                                                expr
                                                                                                                                                                                (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                                                    (|`count.list count.order[0]`_3876|
                                                                                                                                                                                       …
                                                                                                                                                                                expansions
                                                                                                                                                                                • Unsat

                                                                                                                                                                                call `recfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)` from `recfun.remove_imp_orders.remove_imp_orders_side.0 orders`
                                                                                                                                                                                originalrecfun.remove_imp_orders.remove_imp_orders_side.0 orders
                                                                                                                                                                                subrecfun.remove_imp_orders.remove_imp_orders_side.0 (List.tl orders)
                                                                                                                                                                                original ordinalOrdinal.Int (_cnt orders)
                                                                                                                                                                                sub ordinalOrdinal.Int (_cnt (List.tl orders))
                                                                                                                                                                                path[not (List.hd orders).o_is_implied && not Is_a([], orders)]
                                                                                                                                                                                proof
                                                                                                                                                                                detailed proof
                                                                                                                                                                                ground_instances3
                                                                                                                                                                                definitions0
                                                                                                                                                                                inductions0
                                                                                                                                                                                search_time
                                                                                                                                                                                0.025s
                                                                                                                                                                                details
                                                                                                                                                                                Expand
                                                                                                                                                                                smt_stats
                                                                                                                                                                                num checks8
                                                                                                                                                                                arith-assume-eqs15
                                                                                                                                                                                arith-make-feasible76
                                                                                                                                                                                arith-max-columns60
                                                                                                                                                                                arith-conflicts2
                                                                                                                                                                                rlimit count4889
                                                                                                                                                                                mk clause135
                                                                                                                                                                                datatype occurs check54
                                                                                                                                                                                mk bool var303
                                                                                                                                                                                arith-lower44
                                                                                                                                                                                datatype splits39
                                                                                                                                                                                decisions77
                                                                                                                                                                                propagations88
                                                                                                                                                                                interface eqs15
                                                                                                                                                                                arith-max-rows30
                                                                                                                                                                                conflicts7
                                                                                                                                                                                datatype accessor ax31
                                                                                                                                                                                datatype constructor ax59
                                                                                                                                                                                num allocs1507373378
                                                                                                                                                                                final checks21
                                                                                                                                                                                added eqs322
                                                                                                                                                                                del clause101
                                                                                                                                                                                arith eq adapter42
                                                                                                                                                                                arith-upper68
                                                                                                                                                                                memory36.920000
                                                                                                                                                                                max memory67.160000
                                                                                                                                                                                Expand
                                                                                                                                                                                • start[0.025s]
                                                                                                                                                                                    let (_x_0 : int) = count.list count.order orders in
                                                                                                                                                                                    let (_x_1 : order list) = List.tl orders in
                                                                                                                                                                                    let (_x_2 : int) = count.list count.order _x_1 in
                                                                                                                                                                                    let (_x_3 : bool) = (List.hd _x_1).o_is_implied in
                                                                                                                                                                                    let (_x_4 : bool) = not Is_a([], _x_1) in
                                                                                                                                                                                    not (List.hd orders).o_is_implied
                                                                                                                                                                                    && not Is_a([], orders) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                                                                                    ==> not (_x_3 && _x_4) && not (not _x_3 && _x_4)
                                                                                                                                                                                        || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                                                                                • simplify
                                                                                                                                                                                  into
                                                                                                                                                                                  let (_x_0 : order list) = List.tl orders in
                                                                                                                                                                                  let (_x_1 : bool) = (List.hd _x_0).o_is_implied in
                                                                                                                                                                                  let (_x_2 : bool) = not Is_a([], _x_0) in
                                                                                                                                                                                  let (_x_3 : int) = count.list count.order _x_0 in
                                                                                                                                                                                  let (_x_4 : int) = count.list count.order orders in
                                                                                                                                                                                  (not (_x_1 && _x_2) && not (not _x_1 && _x_2)
                                                                                                                                                                                   || Ordinal.( << ) (Ordinal.Int _x_3) (Ordinal.Int _x_4))
                                                                                                                                                                                  || not
                                                                                                                                                                                     (((not (List.hd orders).o_is_implied && not Is_a([], orders)) && _x_4 >= 0)
                                                                                                                                                                                      && _x_3 >= 0)
                                                                                                                                                                                  expansions
                                                                                                                                                                                  []
                                                                                                                                                                                  rewrite_steps
                                                                                                                                                                                    forward_chaining
                                                                                                                                                                                    • unroll
                                                                                                                                                                                      expr
                                                                                                                                                                                      (|`count.list count.order[0]`_3876| orders_3863)
                                                                                                                                                                                      expansions
                                                                                                                                                                                      • unroll
                                                                                                                                                                                        expr
                                                                                                                                                                                        (|`count.list count.order[0]`_3876| (|get.::.1_3862| orders_3863))
                                                                                                                                                                                        expansions
                                                                                                                                                                                        • unroll
                                                                                                                                                                                          expr
                                                                                                                                                                                          (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                                                              (|`count.list count.order[0]`_3876|
                                                                                                                                                                                                 …
                                                                                                                                                                                          expansions
                                                                                                                                                                                          • Unsat

                                                                                                                                                                                          3.4 Implied uncrossing (for single side)

                                                                                                                                                                                          In [23]:
                                                                                                                                                                                          (* The actual cycle *)
                                                                                                                                                                                          let implied_uncross_side (sd : side) (s_id : strategy_id) (s : strategy) (m : market) =
                                                                                                                                                                                          
                                                                                                                                                                                            (* 0. get the top of the book s*)
                                                                                                                                                                                            let book1 = get_book_tops m.out_book1 in
                                                                                                                                                                                            let book2 = get_book_tops m.out_book2 in
                                                                                                                                                                                            let book3 = get_book_tops m.out_book3 in
                                                                                                                                                                                          
                                                                                                                                                                                            let books_tops = { book1; book2; book3 } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 1. calculate the implied orders that are available right now... *)
                                                                                                                                                                                            let imp_order = calc_implied_strat_order s_id s books_tops sd m.curr_time in
                                                                                                                                                                                          
                                                                                                                                                                                            (* Need to increase the order ID first *)
                                                                                                                                                                                            let new_ord_id = m.last_ord_id + 1 in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 2. insert them into the order book *)
                                                                                                                                                                                            let strat_book =
                                                                                                                                                                                              begin
                                                                                                                                                                                                match s_id with
                                                                                                                                                                                                | STRAT1 -> insert_order { imp_order with o_id = new_ord_id } m.s_book1
                                                                                                                                                                                                | STRAT2 -> insert_order { imp_order with o_id = new_ord_id } m.s_book2
                                                                                                                                                                                              end in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 3. perform the uncross - get the fills, etc... *)
                                                                                                                                                                                            let unc_result = uncross_book strat_book [] 0 in
                                                                                                                                                                                          
                                                                                                                                                                                            let fq = unc_result.uncrossed_qty in
                                                                                                                                                                                          
                                                                                                                                                                                            if fq = 0 then
                                                                                                                                                                                              (* Since we didn't trade anything, let's just return the original market state *)
                                                                                                                                                                                              m
                                                                                                                                                                                            else
                                                                                                                                                                                          
                                                                                                                                                                                            let adjust (mult : int) =
                                                                                                                                                                                              let mult = -mult in
                                                                                                                                                                                              if sd = BUY then mult else -mult in
                                                                                                                                                                                          
                                                                                                                                                                                            let adj_mul1 = adjust s.leg1.leg_mult in
                                                                                                                                                                                            let adj_mul2 = adjust s.leg2.leg_mult in
                                                                                                                                                                                            let adj_mul3 = adjust s.leg3.leg_mult in
                                                                                                                                                                                          
                                                                                                                                                                                            (* calculate the prices at which outright orders will trade *)
                                                                                                                                                                                            let price1 = calc_implied_trade_price adj_mul1 book1 in
                                                                                                                                                                                            let price2 = calc_implied_trade_price adj_mul2 book2 in
                                                                                                                                                                                            let price3 = calc_implied_trade_price adj_mul3 book3 in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 4. allocate fills to the outright orders *)
                                                                                                                                                                                            let out_book1_res = allocate_implied_fills m.out_book1 (fq * adj_mul1) price1 m.curr_time in
                                                                                                                                                                                            let out_book2_res = allocate_implied_fills m.out_book2 (fq * adj_mul2) price2 m.curr_time in
                                                                                                                                                                                            let out_book3_res = allocate_implied_fills m.out_book3 (fq * adj_mul3) price3 m.curr_time in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 5. remove the implied orders - notice that the uncrossed result contains a new book
                                                                                                                                                                                              with partial fills *)
                                                                                                                                                                                            let m = match s_id with
                                                                                                                                                                                            | STRAT1 -> { m with s_book1 = remove_imp_orders unc_result.uncrossed_book }
                                                                                                                                                                                            | STRAT2 -> { m with s_book2 = remove_imp_orders unc_result.uncrossed_book } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* 6. let's now gather all of the fills and turn them into outbound messages *)
                                                                                                                                                                                            let new_fill_msgs = create_fill_msgs (unc_result.uncrossed_fills @ out_book1_res.uncrossed_fills
                                                                                                                                                                                              @ out_book2_res.uncrossed_fills @ out_book3_res.uncrossed_fills) in
                                                                                                                                                                                          
                                                                                                                                                                                            { m with
                                                                                                                                                                                              outbound_msgs = new_fill_msgs @ m.outbound_msgs
                                                                                                                                                                                              ; out_book1 = out_book1_res.uncrossed_book
                                                                                                                                                                                              ; out_book2 = out_book2_res.uncrossed_book
                                                                                                                                                                                              ; out_book3 = out_book3_res.uncrossed_book
                                                                                                                                                                                              ; last_ord_id = new_ord_id }
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[23]:
                                                                                                                                                                                          val implied_uncross_side :
                                                                                                                                                                                            side -> strategy_id -> strategy -> market -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          Let's now experiment with some concrete examples.

                                                                                                                                                                                          In [24]:
                                                                                                                                                                                          #program;;
                                                                                                                                                                                          (* #remove_doc doc_of_market;; *)
                                                                                                                                                                                          #logic;;
                                                                                                                                                                                          
                                                                                                                                                                                          let strat = {
                                                                                                                                                                                            time_created = 1;
                                                                                                                                                                                            leg1    = { leg_sec_idx = OUT1; leg_mult = 1 }
                                                                                                                                                                                            ; leg2  = { leg_sec_idx = OUT2; leg_mult = -2 }
                                                                                                                                                                                            ; leg3  = { leg_sec_idx = OUT3; leg_mult = 0 }
                                                                                                                                                                                          };;
                                                                                                                                                                                          
                                                                                                                                                                                          let books = {
                                                                                                                                                                                              book1 = { bid_info = Some { li_qty = 500; li_price = 50 } ; ask_info = Some { li_qty = 750 ; li_price = 50 }}
                                                                                                                                                                                            ; book2 = { bid_info = Some { li_qty = 200 ; li_price = 60 }; ask_info = Some { li_qty = 500 ; li_price = 70 }}
                                                                                                                                                                                            ; book3 = { bid_info = None ; ask_info = None }
                                                                                                                                                                                          };;
                                                                                                                                                                                          
                                                                                                                                                                                          let m = {
                                                                                                                                                                                            curr_time = 1
                                                                                                                                                                                          
                                                                                                                                                                                            ; last_ord_id = 0
                                                                                                                                                                                          
                                                                                                                                                                                            (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                            ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                            (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                            ; strat2 = (make_strat 2 0 1 0)
                                                                                                                                                                                          
                                                                                                                                                                                            (* outright books *)
                                                                                                                                                                                            ; out_book1 = {
                                                                                                                                                                                              b_buys = [ (make BUY 500 50 1 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 750 55 2 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book2 = {
                                                                                                                                                                                              b_buys = [ (make BUY 200 60 3 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 500 70 4 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book3 = {
                                                                                                                                                                                              b_buys = [ ]
                                                                                                                                                                                              ; b_sells = []
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            (* Strategy books *)
                                                                                                                                                                                            ; s_book1 = {
                                                                                                                                                                                              b_buys = [
                                                                                                                                                                                              ]
                                                                                                                                                                                              ; b_sells = [
                                                                                                                                                                                                (make SELL 100 (-100) 5 (Strategy STRAT1) 1 false 1)
                                                                                                                                                                                              ]
                                                                                                                                                                                            }
                                                                                                                                                                                            ; s_book2 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Inbound and outbound message queues *)
                                                                                                                                                                                            ; inbound_msgs = []
                                                                                                                                                                                            ; outbound_msgs = []
                                                                                                                                                                                          } in
                                                                                                                                                                                          
                                                                                                                                                                                          let m' = implied_uncross_side BUY STRAT1 strat m in
                                                                                                                                                                                          
                                                                                                                                                                                          (*calc_implied_strat_order STRAT1 m.strat1 books BUY 1 *)
                                                                                                                                                                                          m'.outbound_msgs
                                                                                                                                                                                          
                                                                                                                                                                                          Out[24]:
                                                                                                                                                                                          val strat : strategy =
                                                                                                                                                                                            {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 1};
                                                                                                                                                                                             leg2 = {leg_sec_idx = OUT2; leg_mult = -2};
                                                                                                                                                                                             leg3 = {leg_sec_idx = OUT3; leg_mult = 0}}
                                                                                                                                                                                          val books : books_info =
                                                                                                                                                                                            {book1 =
                                                                                                                                                                                              {bid_info = Some {li_qty = 500; li_price = 50};
                                                                                                                                                                                               ask_info = Some {li_qty = 750; li_price = 50}};
                                                                                                                                                                                             book2 =
                                                                                                                                                                                              {bid_info = Some {li_qty = 200; li_price = 60};
                                                                                                                                                                                               ask_info = Some {li_qty = 500; li_price = 70}};
                                                                                                                                                                                             book3 = {bid_info = None; ask_info = None}}
                                                                                                                                                                                          - : outbound_msg list =
                                                                                                                                                                                          [Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 100; fill_price = -95; fill_order_id = 5;
                                                                                                                                                                                             fill_order_done = true};
                                                                                                                                                                                           Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 100; fill_price = 50; fill_order_id = 1;
                                                                                                                                                                                             fill_order_done = true};
                                                                                                                                                                                           Fill
                                                                                                                                                                                            {fill_client_id = 1; fill_qty = 200; fill_price = 70; fill_order_id = 4;
                                                                                                                                                                                             fill_order_done = true}]
                                                                                                                                                                                          

                                                                                                                                                                                          3.5 Implied uncrossing decomposition

                                                                                                                                                                                          In [25]:
                                                                                                                                                                                          (* Let's try to decompose the logic of 'implied_uncross_side' - we will put
                                                                                                                                                                                             several functions in the basis to focus on the critical aspects of the logic *)
                                                                                                                                                                                          let d = Modular_decomp.top "implied_uncross_side"
                                                                                                                                                                                                  ~basis:["get_book_tops"; "allocate_implied_fills"; "insert_order";
                                                                                                                                                                                                  "create_fill_msgs"; "calc_implied_strat_order"] ~prune:true [@@program];;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[25]:
                                                                                                                                                                                          val d : Top_result.modular_decomposition =
                                                                                                                                                                                            {Imandra_interactive.Modular_decomp.MD.md_session = 2i;
                                                                                                                                                                                             md_f =
                                                                                                                                                                                              {Imandra_surface.Uid.name = "implied_uncross_side"; id = <abstr>;
                                                                                                                                                                                               special_tag = <abstr>; namespace = <abstr>;
                                                                                                                                                                                               chash = Some 8wTl+x0LfkiILiKj+mPG/aoDyEPbkgCslJNCWuuk+0A;
                                                                                                                                                                                               depth = (6i, 8i)};
                                                                                                                                                                                             md_args = [(sd : side);(s_id : strategy_id);(s : strategy);(m : market)];
                                                                                                                                                                                             md_regions = <abstr>}
                                                                                                                                                                                          
                                                                                                                                                                                          Regions details

                                                                                                                                                                                          No group selected.

                                                                                                                                                                                          • Concrete regions are numbered
                                                                                                                                                                                          • Unnumbered regions are groups whose children share a particular constraint
                                                                                                                                                                                          • Click on a region to view its details
                                                                                                                                                                                          • Double click on a region to zoom in on it
                                                                                                                                                                                          • Shift+double click to zoom out
                                                                                                                                                                                          • Hit escape to reset back to the top
                                                                                                                                                                                          decomp of (implied_uncross_side sd, s_id, s, m
                                                                                                                                                                                          Reg_idConstraintsInvariant
                                                                                                                                                                                          257
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          256
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          255
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          254
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          253
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          252
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          251
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          250
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          249
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          248
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          247
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          246
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          245
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          244
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          243
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          242
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          241
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          240
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          239
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          238
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          237
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          236
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          235
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          234
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          233
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          232
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          231
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          230
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          229
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          228
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          227
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          226
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          225
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          224
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          223
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          222
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          221
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          220
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          219
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          218
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          217
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          216
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          215
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          214
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          213
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          212
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          211
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          210
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          209
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          208
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          207
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          206
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          205
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          204
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          203
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          202
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          201
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          200
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          199
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          198
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          197
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          196
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          195
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          194
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          193
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          192
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          191
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          190
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          189
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          188
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          187
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          186
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          185
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          184
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          183
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          182
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          181
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          180
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          179
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          178
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          177
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          176
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          175
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          174
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          173
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          172
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          171
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          170
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          169
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          168
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          167
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          166
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          165
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          164
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          163
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          162
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          161
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          160
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          159
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          158
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          157
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          156
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          155
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          154
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          153
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          152
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          151
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          150
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          149
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          148
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          147
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          146
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          145
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          144
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          143
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          142
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          141
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          140
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          139
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          138
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          137
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          136
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          135
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          134
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          133
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          132
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          131
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          130
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book2)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book2 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          129
                                                                                                                                                                                          • (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book2)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            = 0
                                                                                                                                                                                          • not Is_a(STRAT1, s_id)
                                                                                                                                                                                          m
                                                                                                                                                                                          128
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          127
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          126
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          125
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          124
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          123
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          122
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          121
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          120
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          119
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          118
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          117
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          116
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          115
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          114
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          113
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          112
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          111
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          110
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          109
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          108
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          107
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          106
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          105
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          104
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          103
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          102
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          101
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          100
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          99
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          98
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          97
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg1.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          96
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          95
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          94
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          93
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          92
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          91
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          90
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          89
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          88
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          87
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          86
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          85
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- (~- s.leg3.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          84
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          83
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          82
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- (~- s.leg2.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          81
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult))
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          80
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          79
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          78
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          77
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          76
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          75
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          74
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          73
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- (~- s.leg2.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          72
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          71
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          70
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- (~- s.leg1.leg_mult)) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          69
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult))
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- (~- s.leg3.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          68
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          67
                                                                                                                                                                                          • not ((~- (~- s.leg3.leg_mult)) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          66
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- (~- s.leg1.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- (~- s.leg2.leg_mult)) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- (~- s.leg3.leg_mult))
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          65
                                                                                                                                                                                          • (~- (~- s.leg3.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg2.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- (~- s.leg1.leg_mult)) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • not (sd = BUY)
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- (~- s.leg1.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- (~- s.leg2.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- (~- s.leg3.leg_mult)) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          64
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          63
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          62
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          61
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          60
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          59
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          58
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          57
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          56
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          55
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          54
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          53
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          52
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          51
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          50
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          49
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          48
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          47
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          46
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          45
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          44
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          43
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          42
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          41
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          40
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          39
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          38
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          37
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          36
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          35
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          34
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          33
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • not ((~- s.leg1.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).bid_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          32
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          31
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          30
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          29
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          28
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          27
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          26
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          25
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          24
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.bid_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          23
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          22
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : best_bid_ask) = get_book_tops _x_5 in
                                                                                                                                                                                          let (_x_7 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = _x_6} sd _x_7
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : int) = _x_8.uncrossed_qty in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_9 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_9 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_9 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_6.ask_info).li_price _x_7
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_13 : book) = _x_8.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_10.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_11.uncrossed_book; out_book3 = _x_12.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_13.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_8.uncrossed_fills
                                                                                                                                                                                            (List.append _x_10.uncrossed_fills
                                                                                                                                                                                             (List.append _x_11.uncrossed_fills _x_12.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          21
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = _x_4; book3 = get_book_tops _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_5 (_x_8 * ~- s.leg3.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          20
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          19
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          18
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_8 * ~- s.leg2.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          17
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : best_bid_ask) = get_book_tops _x_1 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = _x_2; book2 = get_book_tops _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult)
                                                                                                                                                                                                (Option.get _x_2.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          16
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          15
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          14
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          13
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          12
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          11
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          10
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          9
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • not ((~- s.leg2.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).bid_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          8
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.bid_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          7
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          6
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : best_bid_ask) = get_book_tops _x_4 in
                                                                                                                                                                                          let (_x_6 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = _x_5} sd _x_6
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : int) = _x_7.uncrossed_qty in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_8 * ~- s.leg1.leg_mult) 0 _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_8 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_8 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_5.ask_info).li_price _x_6
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_12 : book) = _x_7.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_9.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_10.uncrossed_book; out_book3 = _x_11.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_12.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_7.uncrossed_fills
                                                                                                                                                                                            (List.append _x_9.uncrossed_fills
                                                                                                                                                                                             (List.append _x_10.uncrossed_fills _x_11.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          5
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : best_bid_ask) = get_book_tops _x_2 in
                                                                                                                                                                                          let (_x_4 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = _x_3; book3 = get_book_tops _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult)
                                                                                                                                                                                                (Option.get _x_3.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_4 (_x_7 * ~- s.leg3.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          4
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.bid_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          3
                                                                                                                                                                                          • not ((~- s.leg3.leg_mult) > 0)
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).bid_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          2
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • not Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : best_bid_ask) = get_book_tops _x_3 in
                                                                                                                                                                                          let (_x_5 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_6 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2; book3 = _x_4}
                                                                                                                                                                                                  sd _x_5
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_7 : int) = _x_6.uncrossed_qty in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_7 * ~- s.leg1.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_7 * ~- s.leg2.leg_mult) 0 _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_7 * ~- s.leg3.leg_mult)
                                                                                                                                                                                                (Option.get _x_4.ask_info).li_price _x_5
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_11 : book) = _x_6.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_8.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_9.uncrossed_book; out_book3 = _x_10.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_11.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_6.uncrossed_fills
                                                                                                                                                                                            (List.append _x_8.uncrossed_fills
                                                                                                                                                                                             (List.append _x_9.uncrossed_fills _x_10.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          1
                                                                                                                                                                                          • (~- s.leg3.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book3).ask_info)
                                                                                                                                                                                          • (~- s.leg2.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book2).ask_info)
                                                                                                                                                                                          • (~- s.leg1.leg_mult) > 0
                                                                                                                                                                                          • Is_a(None, (get_book_tops m.out_book1).ask_info)
                                                                                                                                                                                          • sd = BUY
                                                                                                                                                                                          • not
                                                                                                                                                                                            ((uncross_book
                                                                                                                                                                                              (insert_order
                                                                                                                                                                                               {calc_implied_strat_order s_id s
                                                                                                                                                                                                {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                 book3 = get_book_tops m.out_book3}
                                                                                                                                                                                                sd m.curr_time
                                                                                                                                                                                               with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                              [] 0).uncrossed_qty
                                                                                                                                                                                             = 0)
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          let (_x_0 : int) = m.last_ord_id + 1 in
                                                                                                                                                                                          let (_x_1 : book) = m.out_book1 in
                                                                                                                                                                                          let (_x_2 : book) = m.out_book2 in
                                                                                                                                                                                          let (_x_3 : book) = m.out_book3 in
                                                                                                                                                                                          let (_x_4 : int) = m.curr_time in
                                                                                                                                                                                          let (_x_5 : uncross_res)
                                                                                                                                                                                              = uncross_book
                                                                                                                                                                                                (insert_order
                                                                                                                                                                                                 {calc_implied_strat_order s_id s
                                                                                                                                                                                                  {book1 = get_book_tops _x_1; book2 = get_book_tops _x_2;
                                                                                                                                                                                                   book3 = get_book_tops _x_3}
                                                                                                                                                                                                  sd _x_4
                                                                                                                                                                                                 with o_id = _x_0} m.s_book1)
                                                                                                                                                                                                [] 0
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_6 : int) = _x_5.uncrossed_qty in
                                                                                                                                                                                          let (_x_7 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_1 (_x_6 * ~- s.leg1.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_8 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_2 (_x_6 * ~- s.leg2.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_9 : uncross_res)
                                                                                                                                                                                              = allocate_implied_fills _x_3 (_x_6 * ~- s.leg3.leg_mult) 0 _x_4
                                                                                                                                                                                          in
                                                                                                                                                                                          let (_x_10 : book) = _x_5.uncrossed_book in
                                                                                                                                                                                          {m with
                                                                                                                                                                                          last_ord_id = _x_0; out_book1 = _x_7.uncrossed_book;
                                                                                                                                                                                          out_book2 = _x_8.uncrossed_book; out_book3 = _x_9.uncrossed_book;
                                                                                                                                                                                          s_book1 =
                                                                                                                                                                                          {b_buys = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_buys;
                                                                                                                                                                                           b_sells = recfun.remove_imp_orders.remove_imp_orders_side.0 _x_10.b_sells};
                                                                                                                                                                                          outbound_msgs =
                                                                                                                                                                                          List.append
                                                                                                                                                                                          (create_fill_msgs
                                                                                                                                                                                           (List.append _x_5.uncrossed_fills
                                                                                                                                                                                            (List.append _x_7.uncrossed_fills
                                                                                                                                                                                             (List.append _x_8.uncrossed_fills _x_9.uncrossed_fills))))
                                                                                                                                                                                          m.outbound_msgs}
                                                                                                                                                                                          0
                                                                                                                                                                                          • (uncross_book
                                                                                                                                                                                             (insert_order
                                                                                                                                                                                              {calc_implied_strat_order s_id s
                                                                                                                                                                                               {book1 = get_book_tops m.out_book1; book2 = get_book_tops m.out_book2;
                                                                                                                                                                                                book3 = get_book_tops m.out_book3}
                                                                                                                                                                                               sd m.curr_time
                                                                                                                                                                                              with o_id = m.last_ord_id + 1} m.s_book1)
                                                                                                                                                                                             [] 0).uncrossed_qty
                                                                                                                                                                                            = 0
                                                                                                                                                                                          • Is_a(STRAT1, s_id)
                                                                                                                                                                                          m

                                                                                                                                                                                          3.6 Full book implied uncross

                                                                                                                                                                                          In [26]:
                                                                                                                                                                                          (* The implied uncross algorithm *)
                                                                                                                                                                                          let implied_uncross_books (s : strategy_id) (m : market) =
                                                                                                                                                                                            if s = STRAT1 then
                                                                                                                                                                                              begin
                                                                                                                                                                                                let m = implied_uncross_side BUY s m.strat1 m in
                                                                                                                                                                                                implied_uncross_side SELL s m.strat1 m
                                                                                                                                                                                              end
                                                                                                                                                                                            else
                                                                                                                                                                                              begin
                                                                                                                                                                                                let m = implied_uncross_side BUY s m.strat2 m in
                                                                                                                                                                                                implied_uncross_side SELL s m.strat2 m
                                                                                                                                                                                              end
                                                                                                                                                                                          
                                                                                                                                                                                          Out[26]:
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                val implied_uncross_books : strategy_id -> market -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4. Global state transition functions functions

                                                                                                                                                                                          4.1 Insert order

                                                                                                                                                                                          In [27]:
                                                                                                                                                                                          (* Perform operation to create and insert a new order *)
                                                                                                                                                                                          let run_new_order (m : market) (no : new_ord_msg) =
                                                                                                                                                                                            let new_o_id = m.last_ord_id + 1 in
                                                                                                                                                                                            let o = {
                                                                                                                                                                                              o_id = new_o_id
                                                                                                                                                                                              ; o_qty = no.no_qty
                                                                                                                                                                                              ; o_price = no.no_price
                                                                                                                                                                                              ; o_time = m.curr_time
                                                                                                                                                                                              ; o_side = no.no_side
                                                                                                                                                                                              ; o_client_id = no.no_client_id
                                                                                                                                                                                              ; o_inst = no.no_inst_type
                                                                                                                                                                                              ; o_is_implied = false (* these are always outright *)
                                                                                                                                                                                            } in
                                                                                                                                                                                          
                                                                                                                                                                                            let m' =
                                                                                                                                                                                              match no.no_inst_type with
                                                                                                                                                                                              | Strategy STRAT1 -> { m with s_book1 = (insert_order o m.s_book1) }
                                                                                                                                                                                              | Strategy STRAT2 -> { m with s_book2 = (insert_order o m.s_book2) }
                                                                                                                                                                                              | Outright OUT1   -> { m with out_book1 = (insert_order o m.out_book1) }
                                                                                                                                                                                              | Outright OUT2   -> { m with out_book2 = (insert_order o m.out_book2) }
                                                                                                                                                                                              | Outright OUT3   -> { m with out_book3 = (insert_order o m.out_book3) }
                                                                                                                                                                                          
                                                                                                                                                                                            in { m' with last_ord_id = new_o_id }
                                                                                                                                                                                          
                                                                                                                                                                                          Out[27]:
                                                                                                                                                                                          val run_new_order : market -> new_ord_msg -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4.2 Cancel order

                                                                                                                                                                                          In [28]:
                                                                                                                                                                                          (* Cancel an order *)
                                                                                                                                                                                          let run_cancel_order (m : market) (co : cancel_ord_msg) =
                                                                                                                                                                                            match co.co_instrument with
                                                                                                                                                                                            | Strategy STRAT1 -> {m with s_book1 = (cancel_ord_book co m.s_book1)}
                                                                                                                                                                                            | Strategy STRAT2 -> {m with s_book2 = (cancel_ord_book co m.s_book2)}
                                                                                                                                                                                            | Outright OUT1 -> {m with out_book1 = (cancel_ord_book co m.out_book1)}
                                                                                                                                                                                            | Outright OUT2 -> {m with out_book2 = (cancel_ord_book co m.out_book2)}
                                                                                                                                                                                            | Outright OUT3 -> {m with out_book3 = (cancel_ord_book co m.out_book3)}
                                                                                                                                                                                          
                                                                                                                                                                                          Out[28]:
                                                                                                                                                                                          val run_cancel_order : market -> cancel_ord_msg -> market = <fun>
                                                                                                                                                                                          

                                                                                                                                                                                          4.3 Run implied uncross

                                                                                                                                                                                          In [29]:
                                                                                                                                                                                          (* Perform opreation to execute new fill *)
                                                                                                                                                                                          let run_implied_uncross (m : market) =
                                                                                                                                                                                          
                                                                                                                                                                                            (* Do the typical uncross between the strategies *)
                                                                                                                                                                                            let sbook1_res = uncross_book m.s_book1 [] 0 in
                                                                                                                                                                                            let sbook2_res = uncross_book m.s_book2 [] 0 in
                                                                                                                                                                                          
                                                                                                                                                                                            (*  outright books  *)
                                                                                                                                                                                            let obook1_res = uncross_book m.out_book1 [] 0 in
                                                                                                                                                                                            let obook2_res = uncross_book m.out_book2 [] 0 in
                                                                                                                                                                                            let obook3_res = uncross_book m.out_book3 [] 0 in
                                                                                                                                                                                          
                                                                                                                                                                                            (* Now let's update the entire market state *)
                                                                                                                                                                                            let m' = {
                                                                                                                                                                                              m with
                                                                                                                                                                                                s_book1 = sbook1_res.uncrossed_book
                                                                                                                                                                                                ; s_book2 = sbook2_res.uncrossed_book
                                                                                                                                                                                          
                                                                                                                                                                                                ; out_book1 = obook1_res.uncrossed_book
                                                                                                                                                                                                ; out_book2 = obook2_res.uncrossed_book
                                                                                                                                                                                                ; out_book3 = obook3_res.uncrossed_book
                                                                                                                                                                                          
                                                                                                                                                                                                ; outbound_msgs =
                                                                                                                                                                                                    create_fill_msgs (
                                                                                                                                                                                                      sbook1_res.uncrossed_fills @
                                                                                                                                                                                                      sbook2_res.uncrossed_fills @
                                                                                                                                                                                                      obook1_res.uncrossed_fills @
                                                                                                                                                                                                      obook2_res.uncrossed_fills @
                                                                                                                                                                                                      obook3_res.uncrossed_fills )
                                                                                                                                                                                            } in
                                                                                                                                                                                          
                                                                                                                                                                                            (* Now we should be done with uncrossing the books the old way,
                                                                                                                                                                                              let's now create implied orders here.
                                                                                                                                                                                              Notice that we're using the priority function to determine which
                                                                                                                                                                                              strategy order book runs first... *)
                                                                                                                                                                                            if priority_strat m'.strat1 m'.strat2 then
                                                                                                                                                                                              let m' = implied_uncross_books STRAT1 m' in
                                                                                                                                                                                              (implied_uncross_books STRAT2 m')
                                                                                                                                                                                            else
                                                                                                                                                                                              let m' = implied_uncross_books STRAT2 m' in
                                                                                                                                                                                              (implied_uncross_books STRAT1 m')
                                                                                                                                                                                          
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[29]:
                                                                                                                                                                                          val run_implied_uncross : market -> market = <fun>
                                                                                                                                                                                          
                                                                                                                                                                                          In [30]:
                                                                                                                                                                                          (* Now is a time for a full market uncross. *)
                                                                                                                                                                                          
                                                                                                                                                                                          let m2 = {
                                                                                                                                                                                            curr_time = 1
                                                                                                                                                                                          
                                                                                                                                                                                            ; last_ord_id = 0
                                                                                                                                                                                          
                                                                                                                                                                                            (* In a larger model, we can *)
                                                                                                                                                                                            (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                            ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                            (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                            ; strat2 = (make_strat 2 0 1 0)
                                                                                                                                                                                          
                                                                                                                                                                                            (* outright books *)
                                                                                                                                                                                            ; out_book1 = {
                                                                                                                                                                                              b_buys = [ (make BUY 500 50 1 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 750 55 2 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                            }
                                                                                                                                                                                          
                                                                                                                                                                                            ; out_book2 = {
                                                                                                                                                                                              b_buys = [ (make BUY 200 60 3 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                              ; b_sells = [ (make SELL 500 70 4 (Outright OUT1) 1 false 1) ]
                                                                                                                                                                                            }
                                                                                                                                                                                            ; out_book3 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Strategy books *)
                                                                                                                                                                                            ; s_book1 = empty_book
                                                                                                                                                                                            ; s_book2 = empty_book
                                                                                                                                                                                          
                                                                                                                                                                                            (* Inbound and outbound message queues *)
                                                                                                                                                                                            ; inbound_msgs = []
                                                                                                                                                                                            ; outbound_msgs = []
                                                                                                                                                                                          }
                                                                                                                                                                                          
                                                                                                                                                                                          Out[30]:
                                                                                                                                                                                          val m2 : market =
                                                                                                                                                                                            {curr_time = 1; last_ord_id = 0;
                                                                                                                                                                                             strat1 =
                                                                                                                                                                                              {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 2};
                                                                                                                                                                                               leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                                               leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                             strat2 =
                                                                                                                                                                                              {time_created = 2; leg1 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                                                               leg2 = {leg_sec_idx = OUT2; leg_mult = 1};
                                                                                                                                                                                               leg3 = {leg_sec_idx = OUT3; leg_mult = 0}};
                                                                                                                                                                                             out_book1 =
                                                                                                                                                                                              {b_buys =
                                                                                                                                                                                                [{o_qty = 500; o_price = 50; o_time = 1; o_id = 1; o_side = BUY;
                                                                                                                                                                                                  o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
                                                                                                                                                                                               b_sells =
                                                                                                                                                                                                [{o_qty = 750; o_price = 55; o_time = 1; o_id = 2; o_side = SELL;
                                                                                                                                                                                                  o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                                                                                                                                             out_book2 =
                                                                                                                                                                                              {b_buys =
                                                                                                                                                                                                [{o_qty = 200; o_price = 60; o_time = 1; o_id = 3; o_side = BUY;
                                                                                                                                                                                                  o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}];
                                                                                                                                                                                               b_sells =
                                                                                                                                                                                                [{o_qty = 500; o_price = 70; o_time = 1; o_id = 4; o_side = SELL;
                                                                                                                                                                                                  o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                                                                                                                                             out_book3 = {b_buys = []; b_sells = []};
                                                                                                                                                                                             s_book1 = {b_buys = []; b_sells = []};
                                                                                                                                                                                             s_book2 = {b_buys = []; b_sells = []}; inbound_msgs = [];
                                                                                                                                                                                             outbound_msgs = []}
                                                                                                                                                                                          

                                                                                                                                                                                          4.4 Main transition function

                                                                                                                                                                                          This is where we put it all together. Note that this is a 'shortened' version of the full model - in a complete model we would allow new strategies to be created, more intricate state transitions (e.g. auctions) and much more.

                                                                                                                                                                                          In [31]:
                                                                                                                                                                                          (* The main state transition loop of the exchange state *)
                                                                                                                                                                                          let step (m : market) (msg : inbound_msg) =
                                                                                                                                                                                           begin
                                                                                                                                                                                            match msg with
                                                                                                                                                                                            | NewOrder no -> run_new_order m no
                                                                                                                                                                                            | CancelOrder co -> run_cancel_order m co
                                                                                                                                                                                            | ImpliedUncross -> run_implied_uncross m
                                                                                                                                                                                           end
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          let rec run (m: market) (msgs : inbound_msg list) =
                                                                                                                                                                                           match msgs with
                                                                                                                                                                                           | [] -> []
                                                                                                                                                                                           | x::xs -> let m' = step m x in
                                                                                                                                                                                             m' :: (run m' xs)
                                                                                                                                                                                          ;;
                                                                                                                                                                                          
                                                                                                                                                                                          Out[31]:
                                                                                                                                                                                          val step : market -> inbound_msg -> market = <fun>
                                                                                                                                                                                          val run : market -> inbound_msg list -> market list = <fun>
                                                                                                                                                                                          
                                                                                                                                                                                          termination proof

                                                                                                                                                                                          Termination proof

                                                                                                                                                                                          call `run (step m (List.hd msgs)) (List.tl msgs)` from `run m msgs`
                                                                                                                                                                                          originalrun m msgs
                                                                                                                                                                                          subrun (step m (List.hd msgs)) (List.tl msgs)
                                                                                                                                                                                          original ordinalOrdinal.Int (_cnt msgs)
                                                                                                                                                                                          sub ordinalOrdinal.Int (_cnt (List.tl msgs))
                                                                                                                                                                                          path[not Is_a([], msgs)]
                                                                                                                                                                                          proof
                                                                                                                                                                                          detailed proof
                                                                                                                                                                                          ground_instances3
                                                                                                                                                                                          definitions0
                                                                                                                                                                                          inductions0
                                                                                                                                                                                          search_time
                                                                                                                                                                                          0.018s
                                                                                                                                                                                          details
                                                                                                                                                                                          Expand
                                                                                                                                                                                          smt_stats
                                                                                                                                                                                          num checks7
                                                                                                                                                                                          arith-make-feasible72
                                                                                                                                                                                          arith-max-columns58
                                                                                                                                                                                          arith-conflicts9
                                                                                                                                                                                          rlimit count7113
                                                                                                                                                                                          arith-cheap-eqs23
                                                                                                                                                                                          mk clause131
                                                                                                                                                                                          datatype occurs check18
                                                                                                                                                                                          mk bool var434
                                                                                                                                                                                          arith-lower60
                                                                                                                                                                                          arith-diseq13
                                                                                                                                                                                          datatype splits75
                                                                                                                                                                                          decisions150
                                                                                                                                                                                          arith-propagations9
                                                                                                                                                                                          propagations134
                                                                                                                                                                                          arith-bound-propagations-cheap9
                                                                                                                                                                                          arith-max-rows22
                                                                                                                                                                                          conflicts23
                                                                                                                                                                                          datatype accessor ax62
                                                                                                                                                                                          minimized lits2
                                                                                                                                                                                          arith-bound-propagations-lp7
                                                                                                                                                                                          datatype constructor ax104
                                                                                                                                                                                          final checks4
                                                                                                                                                                                          added eqs521
                                                                                                                                                                                          del clause65
                                                                                                                                                                                          arith eq adapter51
                                                                                                                                                                                          arith-upper64
                                                                                                                                                                                          memory591.900000
                                                                                                                                                                                          max memory621.780000
                                                                                                                                                                                          num allocs623944472168.000000
                                                                                                                                                                                          Expand
                                                                                                                                                                                          • start[0.018s]
                                                                                                                                                                                              let (_x_0 : int) = count.list count.inbound_msg msgs in
                                                                                                                                                                                              let (_x_1 : inbound_msg list) = List.tl msgs in
                                                                                                                                                                                              let (_x_2 : int) = count.list count.inbound_msg _x_1 in
                                                                                                                                                                                              not Is_a([], msgs) && _x_0 >= 0 && _x_2 >= 0
                                                                                                                                                                                              ==> Is_a([], _x_1) || Ordinal.( << ) (Ordinal.Int _x_2) (Ordinal.Int _x_0)
                                                                                                                                                                                          • simplify
                                                                                                                                                                                            into
                                                                                                                                                                                            let (_x_0 : inbound_msg list) = List.tl msgs in
                                                                                                                                                                                            let (_x_1 : int) = count.list count.inbound_msg _x_0 in
                                                                                                                                                                                            let (_x_2 : int) = count.list count.inbound_msg msgs in
                                                                                                                                                                                            (Is_a([], _x_0) || Ordinal.( << ) (Ordinal.Int _x_1) (Ordinal.Int _x_2))
                                                                                                                                                                                            || not ((not Is_a([], msgs) && _x_2 >= 0) && _x_1 >= 0)
                                                                                                                                                                                            expansions
                                                                                                                                                                                            []
                                                                                                                                                                                            rewrite_steps
                                                                                                                                                                                              forward_chaining
                                                                                                                                                                                              • unroll
                                                                                                                                                                                                expr
                                                                                                                                                                                                (|`count.list count.inbound_msg[0]`_11633| msgs_11621)
                                                                                                                                                                                                expansions
                                                                                                                                                                                                • unroll
                                                                                                                                                                                                  expr
                                                                                                                                                                                                  (|`count.list count.inbound_msg[0]`_11633| (|get.::.1_11578| msgs_11621))
                                                                                                                                                                                                  expansions
                                                                                                                                                                                                  • unroll
                                                                                                                                                                                                    expr
                                                                                                                                                                                                    (|Ordinal.<<_119| (|Ordinal.Int_108|
                                                                                                                                                                                                                        (|`count.list count.inbound_msg[0]`_11633|
                                                                                                                                                                                                    …
                                                                                                                                                                                                    expansions
                                                                                                                                                                                                    • Unsat

                                                                                                                                                                                                    5. Complete examples

                                                                                                                                                                                                    Now let's have a complete example that shows how to insert and then trade outright and strategy orders

                                                                                                                                                                                                    In [32]:
                                                                                                                                                                                                    let m4 = {
                                                                                                                                                                                                    
                                                                                                                                                                                                      curr_time = 1
                                                                                                                                                                                                    
                                                                                                                                                                                                      ; last_ord_id = 0
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* first strategy is 2*x1 - x2 + x3 *)
                                                                                                                                                                                                      ; strat1 = (make_strat 1 2 (-1) 1)
                                                                                                                                                                                                      (* second strategy is just the 3rd outright security *)
                                                                                                                                                                                                      ; strat2 = (make_strat 2 0 0 1)
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* outright books *)
                                                                                                                                                                                                      ; out_book1 = empty_book
                                                                                                                                                                                                      ; out_book2 = empty_book
                                                                                                                                                                                                      ; out_book3 = empty_book
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* Strategy books *)
                                                                                                                                                                                                      ; s_book1 = empty_book
                                                                                                                                                                                                      ; s_book2 = empty_book
                                                                                                                                                                                                    
                                                                                                                                                                                                      (* Inbound and outbound message queues *)
                                                                                                                                                                                                      ; inbound_msgs = []
                                                                                                                                                                                                      ; outbound_msgs = []
                                                                                                                                                                                                    } in
                                                                                                                                                                                                    
                                                                                                                                                                                                    (* Helper function signature is: 'cid inst qty sd p'*)
                                                                                                                                                                                                    let new_ord1_msg = make_no_msg 1 (Outright OUT1) 100 SELL 75 in
                                                                                                                                                                                                    let new_ord2_msg = make_no_msg 2 (Outright OUT1) 75 BUY 80 in
                                                                                                                                                                                                    let new_ord3_msg = make_no_msg 3 (Outright OUT1) 125 SELL 50 in
                                                                                                                                                                                                    
                                                                                                                                                                                                    run m4 [new_ord1_msg; new_ord2_msg; new_ord3_msg];;
                                                                                                                                                                                                    
                                                                                                                                                                                                    Out[32]:
                                                                                                                                                                                                    - : market list =
                                                                                                                                                                                                    [{curr_time = 1; last_ord_id = 1;
                                                                                                                                                                                                      strat1 =
                                                                                                                                                                                                       {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 2};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      strat2 =
                                                                                                                                                                                                       {time_created = 2; leg1 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      out_book1 =
                                                                                                                                                                                                       {b_buys = [];
                                                                                                                                                                                                        b_sells =
                                                                                                                                                                                                         [{o_qty = 100; o_price = 75; o_time = 1; o_id = 1; o_side = SELL;
                                                                                                                                                                                                           o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                                                                                                                                                      out_book2 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      out_book3 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book1 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book2 = {b_buys = []; b_sells = []}; inbound_msgs = [];
                                                                                                                                                                                                      outbound_msgs = []};
                                                                                                                                                                                                     {curr_time = 1; last_ord_id = 2;
                                                                                                                                                                                                      strat1 =
                                                                                                                                                                                                       {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 2};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      strat2 =
                                                                                                                                                                                                       {time_created = 2; leg1 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      out_book1 =
                                                                                                                                                                                                       {b_buys =
                                                                                                                                                                                                         [{o_qty = 75; o_price = 80; o_time = 1; o_id = 2; o_side = BUY;
                                                                                                                                                                                                           o_client_id = 2; o_inst = Outright OUT1; o_is_implied = false}];
                                                                                                                                                                                                        b_sells =
                                                                                                                                                                                                         [{o_qty = 100; o_price = 75; o_time = 1; o_id = 1; o_side = SELL;
                                                                                                                                                                                                           o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                                                                                                                                                      out_book2 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      out_book3 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book1 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book2 = {b_buys = []; b_sells = []}; inbound_msgs = [];
                                                                                                                                                                                                      outbound_msgs = []};
                                                                                                                                                                                                     {curr_time = 1; last_ord_id = 3;
                                                                                                                                                                                                      strat1 =
                                                                                                                                                                                                       {time_created = 1; leg1 = {leg_sec_idx = OUT1; leg_mult = 2};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = -1};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      strat2 =
                                                                                                                                                                                                       {time_created = 2; leg1 = {leg_sec_idx = OUT1; leg_mult = 0};
                                                                                                                                                                                                        leg2 = {leg_sec_idx = OUT2; leg_mult = 0};
                                                                                                                                                                                                        leg3 = {leg_sec_idx = OUT3; leg_mult = 1}};
                                                                                                                                                                                                      out_book1 =
                                                                                                                                                                                                       {b_buys =
                                                                                                                                                                                                         [{o_qty = 75; o_price = 80; o_time = 1; o_id = 2; o_side = BUY;
                                                                                                                                                                                                           o_client_id = 2; o_inst = Outright OUT1; o_is_implied = false}];
                                                                                                                                                                                                        b_sells =
                                                                                                                                                                                                         [{o_qty = 125; o_price = 50; o_time = 1; o_id = 3; o_side = SELL;
                                                                                                                                                                                                           o_client_id = 3; o_inst = Outright OUT1; o_is_implied = false};
                                                                                                                                                                                                          {o_qty = 100; o_price = 75; o_time = 1; o_id = 1; o_side = SELL;
                                                                                                                                                                                                           o_client_id = 1; o_inst = Outright OUT1; o_is_implied = false}]};
                                                                                                                                                                                                      out_book2 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      out_book3 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book1 = {b_buys = []; b_sells = []};
                                                                                                                                                                                                      s_book2 = {b_buys = []; b_sells = []}; inbound_msgs = [];
                                                                                                                                                                                                      outbound_msgs = []}]